View Full Version : hello world with pointers

10-01-2001, 12:54 PM
I would try this but Im at school. I dont know if this works but it sure is cool if it does.

int main()
char *TextPtr;


*TextPtr+0='h'; // h
*TextPtr+2='e'; // e
*TextPtr+4='l'; // l
*TextPtr+6='l'; // l
*TextPtr+8='o'; // o
return 0;

Just thought I would share that thought.

10-01-2001, 02:26 PM

Look at all these. The value pointed by TextPtr (char) plus 5, and then assign it something. Esentially, you are assigning to a temporary integer. It would need to be like this. *(TextPtr + 5). And even then, you would need to allocate the memory either on the stack.. ie

char* TextPtr = new char[11];

or on the stack

char TextPtr[11];

10-01-2001, 03:08 PM
It should work I think provided your in the right video
mode and that your compiler supports that way of setting a pointer to a integer, some don't. I'll try it and see what happens.

10-01-2001, 03:10 PM
dereferancing as greater precidence than addition though.