Book Error????????

Nov 26, 2018 at 7:47pm
So i retyped this book code in on a c++ compiler and it gave back an error though in the book there is proper output.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 #include <iostream>
using namespace std;

 int main()
 {
int set[8] = {5, 10, 15, 20, 25, 30, 35, 40};
int *nums = set; 


cout << "The numbers in set are:\n";
cout << *nums << " "; 
while (nums < &set[7])
 {
  nums++;
 cout << *nums << " ";
 }

 cout << "\nThe numbers in set backward are:\n";
 cout << *nums << " "; 
 while (nums > set)
{

 nums−−;
 // Display the value pointed to by nums.
cout<<*nums<< " "; 
}
 return 0;
 }

It did not take nums-- but how else is it supposed to reverse the order??
Nov 26, 2018 at 7:52pm
So i tried instead --nums and that worked but why would the book have it the other way? Do compilers not accept minus in front or something?
Last edited on Nov 26, 2018 at 7:52pm
Nov 26, 2018 at 8:04pm
nums−−;

See those two symbols there, that look like this: −− ?

They're not the minus symbol. You've cut and paste this from somewhere, and instead of - you've got .

Only the actual - symbol is accepted.
Nov 26, 2018 at 8:05pm
You've used some kind of fancy "dashes" instead of the plain old minus sign for your --. Just try retyping it.
Nov 26, 2018 at 8:12pm
oh....wow.
Topic archived. No new replies allowed.