Thread: Please Help Salem, I give Up

  1. #1
    Registered User
    Join Date
    Oct 2001

    Unhappy Please Help Salem, I give Up

    Hi m8
    ive just converted my nested if else's to a switch statement and im still have no end of trouble, could you please have a look at it quickly for me, im about to throw this machine out the window, ive been coding for 4 hours this morning and ive about had enough. please help

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Well I don't know - what are you doing

    > void toUpperCase(char *, char *);
    This should have only one parameter, not two

    Then you would call it twice, like so

    I see you're trying to use the Hungarian naming convention by putting various letters in front of the names. Unfortunately, you've got it wrong, so its not helping you, and might actually be hindering you.

    > case "ONE":
    No - this doesn't work
    I don't know what you're trying to achieve here.

    I think you'd be better if the code went something like....
        if (strcmp( pNumberStringPtr, "ONE" ) == 0 )
            return 1;
        if (strcmp( pNumberStringPtr, "TWO" ) == 0 )
            return 1;
        if (strcmp( pNumberStringPtr, "THREE" ) == 0 )
            return 1;
    and you removed all the switch/case statements.

    > strcmp( pNumberStringPtr, "ONE" ) = 0
    This is also wrong, you should have == for comparision, this is an assignment (a bad one at that)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2001
    thanks for the reply salem, my internet connection didnt work all last night so i couldnt check my posting, ive got it sorted now, turned out you cant switch a pointer, i ended up doing like you suggested,

    with respect to the void ........ (char *, char *)
    you need to do that to pass two different char pointers to a function. whether that is good practice or not i dont know though.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Give me some opinions on setting up a server
    By Shadow in forum A Brief History of
    Replies: 12
    Last Post: 04-19-2004, 10:38 AM
  2. Salem
    By unanimous in forum A Brief History of
    Replies: 18
    Last Post: 08-09-2003, 11:39 AM
  3. How to print out the data throw printer.Attn Salem
    By Jason in forum C Programming
    Replies: 2
    Last Post: 09-23-2001, 05:58 AM
  4. How To Give A Font Colour ?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 09-14-2001, 01:22 PM
  5. Just to give you an idea of what we're going through...
    By rick barclay in forum A Brief History of
    Replies: 8
    Last Post: 09-13-2001, 02:09 PM