Please Help Salem, I give Up

This is a discussion on Please Help Salem, I give Up within the C++ Programming forums, part of the General Programming Boards category; Hi m8 ive just converted my nested if else's to a switch statement and im still have no end of ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    34

    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
    Attached Files Attached Files

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    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
    toUpperCase(pNumberString);
    toUpperCase(System);

    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....
    Code:
        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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    34
    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.

    thanks

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 Cprogramming.com
    Replies: 12
    Last Post: 04-19-2004, 10:38 AM
  2. Salem
    By unanimous in forum A Brief History of Cprogramming.com
    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 Cprogramming.com
    Replies: 8
    Last Post: 09-13-2001, 02:09 PM

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