error in devC++
I'm writing a game in C++ and keep getting the error: 3 C:\Dev-Cpp\textgame.cpp expected unqualified-id before '{' token ;
here's source:{
printf("welcome, type your name:")
scanf("%s",&n);
printf("hello %s")
}
please find the error: this is the greeting for the game, once I solve this, I'll work on the rest.
A) you need to post all the code
B) printf("welcome, type your name:") should be printf("welcome, type your name:"); and printf("hello %s") should be printf("hello %s");, you end function calls with a semicolon!
B) printf("welcome, type your name:") should be printf("welcome, type your name:"); and printf("hello %s") should be printf("hello %s");, you end function calls with a semicolon!
Thank you. This is the whole thing though-I only have the greeting ready, working on finding I/O in the help menu for it.
Hey Brandon,
That source code there isn't complete. You're missing out int main()!
You're also missing out any #include statements that may be needed. Finally, you need to return 0 at the end of int main() (although some compilers add this in for you).
C++ takes advantage of better ways for text I/O. Instead of using printf() I recommend you use std::cout and instead of using scanf() I recommend you use std::cin. The functions printf() and scanf() are generally used in C rather than C++.
Best of luck to you :-).
That source code there isn't complete. You're missing out int main()!
You're also missing out any #include statements that may be needed. Finally, you need to return 0 at the end of int main() (although some compilers add this in for you).
C++ takes advantage of better ways for text I/O. Instead of using printf() I recommend you use std::cout and instead of using scanf() I recommend you use std::cin. The functions printf() and scanf() are generally used in C rather than C++.
Best of luck to you :-).
Brandon I recommend you read some tutorials for getting started in C++ programming.
Cprogramming has a fantastic beginners tutorial with quizes to help you understand your own code aswell as learn new things!
Try this:
Please not that this is a C program and NOT a C++ program.
Cprogramming has a fantastic beginners tutorial with quizes to help you understand your own code aswell as learn new things!
Try this:
#include <cstdio>int main() { char* n; printf("welcome, type your name:"); scanf("%s",&n); printf("hello %s", &n);}
Please not that this is a C program and NOT a C++ program.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement