Thread: Character problem

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    1

    Character problem

    Hi,
    I have a problem. I have this code (reading a word and writing the number of it s characters), and I don't know how to add a for cicle to write every character of the word.
    So can you help me?

    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main ()
    {
    char szInput[256];
    printf ("Enter a sentence: ");
    gets (szInput);
    printf ("The sentence entered is %u characters long.\n",strlen(szInput));
    return 0;
    }

  2. #2
    Super unModrator
    Join Date
    Dec 2007
    Posts
    321
    Quote Originally Posted by popescuradhoo View Post
    Hi,
    I don't know how to add a for cicle to write every character of the word.
    What's a cicle?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Read the FAQ on using (or more accurately, NOT using) gets()
    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.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Think this person wants to know how to use a for loop to print each letter in the string.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. about wide character and multiple byte character
    By George2 in forum C Programming
    Replies: 3
    Last Post: 05-22-2006, 08:11 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. printing strings (was similar problem)
    By weirdbeardmt in forum C Programming
    Replies: 5
    Last Post: 06-01-2004, 01:12 PM
  4. problem comparing character
    By winsonlee in forum C Programming
    Replies: 2
    Last Post: 03-19-2004, 12:15 PM
  5. Problem with character arrays in classes
    By spoketoosoon in forum C++ Programming
    Replies: 3
    Last Post: 03-16-2004, 03:57 AM