Why the error ?Code:#include <stdio.h> int main() { char a[]="Hello"; while (*a!='\0') { printf("%c", *a); a++; } return 0; }
Why the error ?Code:#include <stdio.h> int main() { char a[]="Hello"; while (*a!='\0') { printf("%c", *a); a++; } return 0; }
a is an array, hence it cannot be modified in itself. You should create a pointer to char to point to the first character of a.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Thank you.
PS:In gcc no conio.h, what is the alternative?
What are you trying to do that required something in conio.h?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
getch(), putch(), etc
Why do you need getch(), putch(), etc?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
laserlight
For doing exercise in my book.
qny
aware of that, qny
In that case, just substitute with the standard library near-equivalents. They certainly don't do the exact same thing, but for the purposes of learning, they will be as adequate. This way, your code will be more portable, what you learn will have somewhat greater applicability, and if you post your code here, people will more likely be able to quickly get up to speed with it.Originally Posted by justine
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I was checking the action of each function:
I heard about "using namespace std" something like that?Code:#include <stdio.h> using namespace stdin; int main() { char ch; printf("Press ant key to continue\n"); getch(); printf("Press ant key to continue\n"); ch=getche(); printf("Press ant key to continue\n"); getchar(); printf("Continue Y/N"); fgetchar(); return 0; }
Well, do you really need this "press any key to continue" feature?
That is C++.Originally Posted by justine
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
If you can't test the functions, you can read about them and work out what they are supposed to do.
The MSDN site is probably best for that
But whilst reading them, remember that in this day and age they are very uncommon.
Fact - Beethoven wrote his first symphony in C
Okey.