Character problem

This is a discussion on Character problem within the C Programming forums, part of the General Programming Boards category; Hi, I have a problem. I have this code (reading a word and writing the number of it s characters), ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,649
    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, 01: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, 11:15 AM
  5. Problem with character arrays in classes
    By spoketoosoon in forum C++ Programming
    Replies: 3
    Last Post: 03-16-2004, 02:57 AM

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