Thread: printing

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    printing

    sup all i am just practicing in pointers so i can learn it well .. ok i have creating this little wantabe programm.. now there is nothing wrong with it.. but i want to know how can i make the output print in a line instead of it going up... (sorry i dont know how to explain very well) here is the code

    Code:
    int main()
    {
    
       char hello[27] = "abcdefghijklmnopqrstuvwxyz";
       char *p;
       int i;
       p = hello;
    
        for (i=0; p[i]; i++)
        printf("%c\n",p[i]);
        return 0;
    
     }
    i want it like

    abcdefghijg etc..
    not
    a
    b
    c
    d
    etc.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Then remove the "\n" from the printf

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    ok but how did you know that..... this is my point how would i figure that out if i was not to post in here..? educate me please

  4. #4
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    "\n" starts a new line
    with no "\n" no new line will be started
    hello, internet!

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793


    You learn by reading & experimenting.....it just takes a little effort and time.....

    BTW, \n is an alias for the 10th ASCII char.....it's usually used to denote a Line feed....

    Here...save this gif to your computer for reference

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# Printing Problem
    By silverlight001 in forum C# Programming
    Replies: 0
    Last Post: 03-23-2009, 01:13 AM
  2. generic printing preferences dialog box
    By stanlvw in forum Windows Programming
    Replies: 8
    Last Post: 06-27-2008, 02:20 AM
  3. printing data to a file
    By coralreef in forum C Programming
    Replies: 3
    Last Post: 11-02-2006, 08:10 PM
  4. need help relating printing?
    By omarlodhi in forum Linux Programming
    Replies: 0
    Last Post: 03-03-2006, 04:46 AM
  5. Printing
    By Dual-Catfish in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 05-25-2002, 08:10 PM