What am I doing wrong?

This is a discussion on What am I doing wrong? within the C Programming forums, part of the General Programming Boards category; Hello, I have to use a width modifier in the following program. #include <stdio.h> main () { printf("%10s%10s%10s%10s%10s\n", "Parrots","Rams", "Kings", ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    34

    What am I doing wrong?

    Hello,
    I have to use a width modifier in the following program.

    #include <stdio.h>

    main ()

    {

    printf("%10s%10s%10s%10s%10s\n",

    "Parrots","Rams", "Kings", "Titans", "Chargers");

    printf("%10d%10d%10d%10d%10d\n", 3,5,2,1,0);
    printf("%10d%10d%10d%10d%10d\n", 2,5,1,0,1);
    printf("%10d%10d%10d%10d%10d\n", 2,6,4,3,0);

    return;

    }

    1.I get an error at the first printf(): String crosses a line?
    2.I cannot get the teams in one column, with the scores
    beneath them. What am I doing wrong?

    Thanks,

    Adock.

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    I also compiled it (except I put in int main, like you're supposed to, and changed it to return 0 instead of return), and it worked just peachy - everything lined up right.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    34

    Re: What am I doing wrong?

    Hello,
    I've tried your suggestions: int main ()

    return 0;

    The problem still persists.

    Adock.

  4. #4
    Unregistered
    Guest
    I compiled and ran with VC++ 5.0 and it works fine. Must be your Compiler or possibly try this:

    printf("%10s%10s%10s%10s%10s\n",

    "Parrots","Rams", "Kings", "Titans", "Chargers");


    make it one line:

    printf("%10s%10s%10s%10s%10s\n", "Parrots", "Rams", "Kings", "Titans", "Chargers");

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    34

    Re:What am I doing wrong?

    Hello Salem,
    I took your hint, and compiled
    the above successfully with Dev.C++.

    For your info. I was using Miracle C,
    plus Win'98 O/S.

    Thanks for your time and support.

    Adock.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 04:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 01:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 02:04 PM

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