Code:void main(void) { char what[24]; fgets(what,24)); int base; base = atoi(what); char * address = base; while(1) printf("%i", (char)*address++); return; }
Code:void main(void) { char what[24]; fgets(what,24)); int base; base = atoi(what); char * address = base; while(1) printf("%i", (char)*address++); return; }
this is pointing to the converted int, proabally some ram already used. you want to add the '&' sign to base so it points to where it is and not what it holds.char * address = base;
>>void main( void )
BADBADBADBADBADBADBADBAD!!!!
Use int main( void ) and return 0;
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
This code wouldn't compile.
1) This line is wrong:
void main(void)
2) This is wrong:
Do you even listen to your compiler? You have two ')' there when you should just have one.Code:char what[24]; fgets( what,24 ) ); int base; base = atoi(what);
Furthermore, this is C, not C++. As such, you cannot radomly declare new variables wherever you like, unless by some odd chance, you happen to have a C99 compatible compiler.
3) This is also wrong, as described in the first post.
char * address = base;
4) What are you doing?
while(1) printf("%i", (char)*address++);
This code will print out characters (as numbers) forever and ever and ever and ever. And why are you typcasting here? Use %c if you want characters, otherwise, lose the cast. My guess is that you're trying to do something your compiler is warning about, so you're trying to hide the warning.
The above line is also a potential cause of access violation, because of your foolish while loop.
Quzah.
Hope is the first step on the road to disappointment.
Also
fgets(what,24, stdin);
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers