Beginner in C, help plese with

This is a discussion on Beginner in C, help plese with within the C Programming forums, part of the General Programming Boards category; I'm trying to create a function, in 2 lines, that will read commands in a way that is not case ...

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    1

    Beginner in C, help plese with

    I'm trying to create a function, in 2 lines, that will read commands in a way that is not case sentient.

    ex. If I type qUIt, it'll read it as quit.

    I've agonized over this for hours and came up with

    insert
    Code:
    for (i = 0; line[i] != '\0'; i++) {
          number = myString[i] - '0';
    }
    It doesn't work, but am I at least on the right path?
    Any help will be very welcome, thanks!

  2. #2
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    In each iteration of the loop, you are storing something in the variable 'number' but on the next iteration you store something new there.

    And how come you refer to your string as line[] in the head of the loop but as myString[] in the body?

    Lastly, why are you subtracting the value of the digit '0' from things? What does zero have to do with upper and lower case?
    Code:
    while(!asleep) {
       sheep++;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. plese help
    By amnathebiitch in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2011, 06:31 AM
  2. IF CONDITION plese help
    By birumut in forum C Programming
    Replies: 12
    Last Post: 03-06-2009, 09:48 PM
  3. External Counter, Plese Help
    By SMTU_1 in forum C Programming
    Replies: 8
    Last Post: 08-01-2007, 02:50 AM
  4. compiling... plese help
    By g_harl in forum C Programming
    Replies: 1
    Last Post: 03-09-2003, 01:00 PM
  5. can some one plese help me!!!!!!!!!
    By head in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2002, 02:25 PM

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