A very stupid newbie question

This is a discussion on A very stupid newbie question within the C Programming forums, part of the General Programming Boards category; Hello all. I am brand new to C/C++, in fact I am taking a course on it as we speak. ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    2

    A very stupid newbie question

    Hello all. I am brand new to C/C++, in fact I am taking a course on it as we speak.

    I am hung up on our very first program and I need to make sure I'm not doing something stupid.

    Basically, I can't get /n or /r to carriage return to a new line. Here is my code:
    Code:
    #include<stdio.h>
    
    main()
    {
         printf("Testing.../n..1/n...2/n....3/n");
    }
    [code tags added by ygfperson]
    Pretty simple huh....

    Now here is the output I receive:

    Testing.../n..1/n...2/n....3/n

    What am I doing wrong? I have tried compiling this in Vis C++ and in Devcpp 4.... I realize I'm new to this but it's gonna be a long class if I can't get past this!

    TIA for your help!

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Try \n not /n


  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    2
    Thank you kind sir. That's all it was.... Apparently my class notes were wrong!!!

  4. #4
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    You could make it really fancy if you wanted:
    Code:
    #include <stdio.h>
    
    int main ( void )
    {
    	int Counter;
    	printf("Testing..\n");
    	for ( Counter = 1; Counter < 4; Counter++ )
    	{
    		printf("%i\n", Counter);
    	}
    	return 0;
    }
    The world is waiting. I must leave you now.

  5. #5
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356
    Originally posted by Shadow
    You could make it really fancy if you wanted:
    Code:
    #include <stdio.h>
    
    int main ( void )
    {
    	int Counter;
    	printf("Testing..\n");
    	for ( Counter = 1; Counter < 4; Counter++ )
    	{
    		printf("%i\n", Counter);
    	}
    	return 0;
    }
    What is %i ..Used for integers????Never seen anything like that before??? I would like an explanation

    DaIn
    "I wish i could wish my wishs away"

    "By indirections find directions out" -- William Shakespears

    "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"

    Mizra -> love = Death...
    RDB(Rocks yooo)..

    http://www.cbeginnersunited.com

    Are you ready for the Trix ???

  6. #6
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    %i is conversion specification for a signed decimal integer. Same as %d

    Mr. C

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    16
    Oh just thought you would also want to know how to print out the backslash (\) character too
    you just do \\
    and \' to print out '
    \" to print out "
    \? to print out ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 08:22 PM
  2. Stupid newbie question
    By CompiledMonkey in forum C++ Programming
    Replies: 6
    Last Post: 06-06-2004, 01:32 PM
  3. Stupid Question
    By Labelizm in forum Windows Programming
    Replies: 2
    Last Post: 07-24-2002, 05:59 AM
  4. very newbie question: how to copy files
    By webwesen in forum C Programming
    Replies: 26
    Last Post: 04-25-2002, 04:01 PM
  5. Episode II Return Of the newbie : Website IO Question
    By MagiZedd in forum Windows Programming
    Replies: 1
    Last Post: 10-18-2001, 09:58 PM

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