Re: [Dev-C++] compilation error with ++ operator on char array
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: w.y. <yok...@ve...> - 2003-08-16 09:57:59
|
Dawood Vora wrote: > > The offending line is if (*inp++ == '?') count++; But the funny > thing is if I substitute p for inp in the while loop, then it compiles > and gives me the right answer. That is normal behavior. > I am under the impression that the post and pre increment operators > can be used on the names of char arrays. Somebody, please clear me on > this and give me some plausible explanation. > > char inp[] = "?cmewop? OWCOIJJJ?mcjmwow? cwjw?xjw?"; When you declare an array like this, 'inp' is essentially _constant_ and always contains the address of the first array element during its lifetime. > char* p = inp; p however you can change around as you already know. |