0
#include<iostream> #include<conio.h> #include<stdio.h> void main() { int i; char str[80]; cout<<"enter any name"; gets(str); for(i=0;str[i]!='\0';i++) {cout<<str[i]<<"\n"; } getch(); }
what's wrong in this code?
21 Antworten
0
What error do you get?
0
so many errors like return type should be int in void main() , etc
0
Now I see, you didn't mean compiler errors... It's in many parts not ideal to say the least. It's pretty much C, not C++. There's a potential buffer overflow, the output is not done as easy and straightforward as could be... the input, too.
0
Welp I figured out that , I need pure c++ like the one we usually have in PC , is turbo c++ the option?
0
Kshitij, what does that mean? Against which compiler are you writing your code? There are so many compilers and language versions that this can be a topic of severe confusion... Pls state name and version and the intended language standard (as modern compilers support C++03, 11, 14 and some features of C++17)
0
yeah I've guessed something like that. I just need my code to run properly. well I'm a PC user so it's kinda different.I use turbo c++ on PC but as u said its pretty much C so...
0
it's purely beginner code I've written just to check. I thought it would run but oh well XD
0
As you are not stating your compiler I cannot check if any source code I want to suggest compiles on that compiler. I only know Borlands Turbo C++ 3.1 from the time I went to school and wrote my first C++ programs...
Anyways, pls tell me how can I help with such an exotic and maybe very outdated compiler?
0
I'm just using this app to run my program. does the compiler has anything to do what Android OS I'm using? I don't think so
0
So apart from the int return type you do not write "using namespace std;" or prepend "std::" to your "cout". As "cout" is in the namespace "std", the symbol "cout" cannot be resolved. Do one of the suggestions.
The better one in my opinion is to prepend "std::"
0
alright I think I got you. thanks!
0
#include<iostream.h> use it
0
anyone can you help me? C++ challenge question number 5 can you help me to answer that arrangement.
0
@Terence John J. Morilao: Pls open a separate thread so others can find your question and may profit from the answers the questions and the answers.
0
put at the begining:
for(int y = 0; y <80;y++)
{
str[i] = NULL;
}
0
i think error may be { }
0
i think....error may be { }
0
rgh
0
write" using namespace std;" after all includes
and before void main ()
change void main to int main
and add "return 0;" after getch ()
and that should do it
0
#include<iostream.h>