Thread: printing out strings

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    96

    printing out strings

    hi i am trying to print out string are this sysntax wrong is this how i declare [I] or do i use int iam a beginner just trying to experiment
    Code:
     
    char scores[50], i;
    printf("enter name");
    scanf("\n%s", scores[i]);
    printf("\n%s",scores[i]);

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Your syntax is fine. What is wrong is that you should pass scores, not scores[i] to scanf and printf. In fact, you should not use i because it has not been initialised.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User UltraKing227's Avatar
    Join Date
    Jan 2010
    Location
    USA, New york
    Posts
    123
    i agree with laserlight.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. printing strings
    By Tom_Arch in forum C Programming
    Replies: 4
    Last Post: 04-25-2009, 03:23 AM
  2. printing wide characters to strings...
    By davo666 in forum C Programming
    Replies: 1
    Last Post: 02-21-2009, 12:56 AM
  3. printing char* strings
    By difficult.name in forum C Programming
    Replies: 4
    Last Post: 12-10-2004, 07:06 PM
  4. printing strings (was similar problem)
    By weirdbeardmt in forum C Programming
    Replies: 5
    Last Post: 06-01-2004, 01:12 PM
  5. printing an array of strings
    By linucksrox in forum C Programming
    Replies: 3
    Last Post: 05-11-2004, 03:31 PM