and the questions keep coming

This is a discussion on and the questions keep coming within the C++ Programming forums, part of the General Programming Boards category; sorry about all of these questions lately, but ive been working hard on this game, and because its so complex, ...

  1. #1
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465

    and the questions keep coming

    sorry about all of these questions lately, but ive been working hard on this game, and because its so complex, im running into endless streams of problems...

    first of all, i have a while loop that wont break.

    while ( ( value1 > 0 ) || ( value2 > 0 ) )

    no matter how low either value gets, the loop keeps running...

    and i have string problems too....

    i have a little thing that goes something like this:

    char string[10] = "hi";
    printf("%s", string);

    and it gives an output of a bunch of weird characters (like smiley faces, hearts, etc...)
    I came up with a cool phrase to put down here, but i forgot it...

  2. #2
    Unregistered
    Guest
    Don't know about the printf, but your first problem might be from your condition. As long as either value1 or value2 is greater than 0, the condition is true. Try manually setting both to 0 and see what happens.

  3. #3
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    well, the problem im having is that these values get way into the negatives, and it still continues the loop.

    unless they changed something since i last checked, a negative number is less than 0.


    *slaps forhead*

    i just realized..... because i have an 'or' operator in there, the value that is positive keeps the loop going.

    *looks at signature*

    well, at least the second problem is still getting on my nerves.
    Last edited by ...; 03-13-2002 at 08:15 PM.
    I came up with a cool phrase to put down here, but i forgot it...

  4. #4
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    *edited*

    changed my mind..... the loop problem was a computer error, not a coding error.

    still cant get strings working though... not correctly, anyway.
    Last edited by ...; 03-13-2002 at 08:35 PM.
    I came up with a cool phrase to put down here, but i forgot it...

  5. #5
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    char string[3] = "hi";
    printf("%s", string);

    Works for me.

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    29
    For the While Problem (if you change || to &&) you will have to set the values to 0 to break the loop. The loop will break if values are int at the MAXINT which is 32767. The next number is-32768 (#include<limits.h>).

    About the printf, this works fine, if not try cout << string;

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21