I am brand new to programming and i am using sams C in 21 days, dont really expect that to happen but hopefully i will have the basics down. Anyway i inputted the following code exactly as the book shows and i got a bunch of errors such as "Line 1 parse error before ' \' but the weird thing is, is it tells me i have errors on lines 319 upto 333, and i am no where close to using that many lines. OK i am using Dev C++ compiler the newest version, i believe its 4.9.7.0 and i saved this program as "first.c" This is a C book not C++ or C#. here it is.
//Sample.c
#include <stdlib.h>
int main ( void )
{
printf("Dev-C++ program at work!");
system("PAUSE");
return 0;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your comment is C++ formatted, but, because you saved it as a .c format, its trying to compile as a C program. It will compile as a C++ program
I also doubt that you copied it down "exactly". In addition to the above language error, you did not include stdio.h, which you need for printf to work.
This code, based on yours, will compile and run as a C program:
#include <stdlib.h>
#include <stdio.h>
int main ( void )
{
printf("Dev-C++ program at work!");
system("PAUSE");
return 0;
}
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks wayne.
I did double check my typing and i did type it exactly as it shows on page 887 of sams learn c in 21days. What is bugging me now is that this is supposed to be a C format book but you are saying that the format is in c++. No wonder none of the programs I am typing from this book are working for me. I will try them as C++ programs. Thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am new to programming and about to start a programming coarse over the internet, anyway I am about to start C and I would like to know which compiler I should use? and any other general advise you could give would be great.
Thanks
Karl
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am brand new to programming and i am using sams C in 21 days, dont really expect that to happen but hopefully i will have the basics down. Anyway i inputted the following code exactly as the book shows and i got a bunch of errors such as "Line 1 parse error before ' \' but the weird thing is, is it tells me i have errors on lines 319 upto 333, and i am no where close to using that many lines. OK i am using Dev C++ compiler the newest version, i believe its 4.9.7.0 and i saved this program as "first.c" This is a C book not C++ or C#. here it is.
//Sample.c
#include <stdlib.h>
int main ( void )
{
printf("Dev-C++ program at work!");
system("PAUSE");
return 0;
}
Your comment is C++ formatted, but, because you saved it as a .c format, its trying to compile as a C program. It will compile as a C++ program
I also doubt that you copied it down "exactly". In addition to the above language error, you did not include stdio.h, which you need for printf to work.
This code, based on yours, will compile and run as a C program:
#include <stdlib.h>
#include <stdio.h>
int main ( void )
{
printf("Dev-C++ program at work!");
system("PAUSE");
return 0;
}
Wayne
Oops, im already able to do some hello world programs hehehe but i didnt know nothing about that comment things.
So Wayne, when adding comments to C programs we should always use /* */ and for C++ programs we Can use bot // and /* */ , is that it ?
That is correct, you can use whichever suites your needs in C++.
Note that once the stdio.h is added, the code compiles if you save it as a c++ file, i.e. waynesanidiot.cpp.
Wayne
p.s. don't let this put you off comments.
Thanks wayne.
I did double check my typing and i did type it exactly as it shows on page 887 of sams learn c in 21days. What is bugging me now is that this is supposed to be a C format book but you are saying that the format is in c++. No wonder none of the programs I am typing from this book are working for me. I will try them as C++ programs. Thanks again.
Could anyone please give me some advise?
I am new to programming and about to start a programming coarse over the internet, anyway I am about to start C and I would like to know which compiler I should use? and any other general advise you could give would be great.
Thanks
Karl
See my post on the new thread you started, I recommend the LCC C compiler.
Wayne