Thread: hello world with pointers

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    140

    hello world with pointers

    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=0xB800;

    *TextPtr+0='h'; // h
    *TextPtr+1=7;
    *TextPtr+2='e'; // e
    *TextPtr+3=7;
    *TextPtr+4='l'; // l
    *TextPtr+5=7;
    *TextPtr+6='l'; // l
    *TextPtr+7=7;
    *TextPtr+8='o'; // o
    return 0;
    }

    Just thought I would share that thought.
    Last edited by stupid_mutt; 10-01-2001 at 12:58 PM.

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    *TextPtr+5

    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];
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    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.

  4. #4
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    dereferancing as greater precidence than addition though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  2. Too much to ask ?
    By deflamol in forum C Programming
    Replies: 2
    Last Post: 05-06-2004, 04:30 PM
  3. Pointers pointers pointers....
    By G'n'R in forum C Programming
    Replies: 11
    Last Post: 11-02-2001, 02:02 AM
  4. Pointers pointers pointers...
    By SMurf in forum C Programming
    Replies: 8
    Last Post: 10-23-2001, 04:55 PM
  5. No More Technology After World War Three
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-20-2001, 07:02 PM