#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    28
    Rep Power
    0

    Unhappy C Programing- how can i add a new line?


    hi there,
    I am new learner of C programming. while i was learning i was trying a problem, where it is said that after 5 prints of numbers i have to add a new line. i tried to do the code as following but its giving me an error

    my code

    # include <stdio.h>

    int main () {
    int x=1;
    while (x<=20)
    {
    printf ("%d ",x);
    if (x/5==0){
    printf('\n');
    }
    x++;
    }
    return 0;
    }
    Error I get :

    ex4.3.3.c: In function ‘main’:
    ex4.3.3.c:9:3: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast [enabled by default]
    /usr/include/stdio.h:363:12: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
    ex4.3.3.c:9:3: wa
    I am using Ubuntu to execute my c program.
    what should i done to overcome my problem?

    Thanks
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    c Code:
    printf('\n');

    printf() needs an actual string, not a character.
    c Code:
    printf("\n");
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by requinix
    c Code:
    printf('\n');

    printf() needs an actual string, not a character.
    c Code:
    printf("\n");
    thanks...

IMN logo majestic logo threadwatch logo seochat tools logo