Alright, first off I am just learning C++ from an eBook I found online. The problem is they are very vague on compiling things so I kind of "winged" it to check to see if my "exercise" code is correct.
Basically I have exer1.c:
char LetterCode;
double SalePrice;
long Quantity;
Lettercode = 'v';
SalePrice = 67.95;
Quantity = 1000000;
- char LetterCode;
- double SalePrice;
- long Quantity;
- Lettercode = 'v';
- SalePrice = 67.95;
- Quantity = 1000000;
I load up Konsole and type g++ exer1.c and I get these errors:
exer1.c:5: ISO C++ forbids declaration of `Lettercode' with no type
exer1.c:6: ISO C++ forbids declaration of `SalePrice' with no type
exer1.c:6: conflicting types for `int SalePrice'
exer1.c:2: previous declaration as `double SalePrice'
exer1.c:6: warning: initialization to `int' from `double'
exer1.c:6: warning: argument to `int' from `double'
exer1.c:7: ISO C++ forbids declaration of `Quantity' with no type
exer1.c:7: conflicting types for `int Quantity'
exer1.c:3: previous declaration as `long int Quantity'
exer1.c:7:23: warning: no newline at end of file
So I try to debug the errors, by commenting out the first three lines and defining the variables with their assignment line like so:
//char LetterCode;
//double SalePrice;
//long Quantity;
char Lettercode = 'v';
double SalePrice = 67.95;
long Quantity = 1000000;
- //char LetterCode;
- //double SalePrice;
- //long Quantity;
- char Lettercode = 'v';
- double SalePrice = 67.95;
- long Quantity = 1000000;
And this comes up with 'g++ exer1.c':
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
So I have no idea what that means, and I don't know why I have to declare the variable type with its value assignment, any ideas why this isn't working, or do I have it right and just can't compile without some sort of "real" script?
Pixel Acres V2