Why the error ?Code:#include <stdio.h> int main() { char a[]="Hello"; while (*a!='\0') { printf("%c", *a); a++; } return 0; }
This is a discussion on lvalue required as increment operand within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> int main() { char a[]="Hello"; while (*a!='
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.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
Thank you.
PS:In gcc no conio.h, what is the alternative?
What are you trying to do that required something in conio.h?
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
getch(), putch(), etc
Why do you need getch(), putch(), etc?
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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.