Thread: New To C Programming

  1. #1
    Registered User
    Join Date
    Nov 2011
    Location
    Nottingham, United Kingdom, United Kingdom
    Posts
    5

    New To C Programming

    Hi everyone,

    I am not new to programming in general but new to the C programming language. I have only tried C for a few hours now. I am not using a tutorial as such but learning from a standard library reference.

    When looking at this simple example of a For statement:
    Code:
    
    for(loop=0;loop<1000;loop++)
    
      printf("%i\n",loop);
    Can anyone tell me what %i does? If this is removed the string will not be printed. How does this work?

    If anyone wants more information please just ask, and i'll try explain in more detail.

    Thanks.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well... if you have a standard library reference you should look up printf() and see for yourself...

  3. #3
    Registered User
    Join Date
    Nov 2011
    Location
    Nottingham, United Kingdom, United Kingdom
    Posts
    5
    Quote Originally Posted by CommonTater View Post
    Well... if you have a standard library reference you should look up printf() and see for yourself...
    That doesn't answer my question at all, if the answer was in the language reference I was using then I wouldn't be posting here, if I knew what I was searching for on Google then I wouldn't be posting here. Hence the reason I am posting here.

    Why waste your time replying by not giving an answer?

  4. #4
    Registered User
    Join Date
    Aug 2008
    Location
    Belgrade, Serbia
    Posts
    163
    The C Standard Library

    Also, the man page:
    d, i The int argument is converted to signed decimal notation. The precision, if any,
    gives the minimum number of digits that must appear; if the converted value
    requires fewer digits, it is padded on the left with zeros. The default precision
    is 1. When 0 is printed with an explicit precision 0, the output is empty.
    Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
    What profit hath a man of all his labour which he taketh under the sun?
    All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
    For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Wellll.... how about THIS

    Also if you are reading a C library reference, printf() will be documented in it.

    Really....

  6. #6
    Registered User
    Join Date
    Nov 2011
    Location
    Nottingham, United Kingdom, United Kingdom
    Posts
    5
    Quote Originally Posted by CommonTater View Post
    Wellll.... how about THIS

    Also if you are reading a C library reference, printf() will be documented in it.

    Really....
    Printf() is documented just not very detailed, I did not think of putting Printf() in Google as I didn't know if %i is just related to the function. Anyway I fount the answer to my question.

    Thanks.

  7. #7
    Registered User
    Join Date
    Nov 2011
    Posts
    161
    If this is how you plan to learn C, it's going to be a long road.

  8. #8
    Registered User
    Join Date
    Nov 2011
    Location
    Nottingham, United Kingdom, United Kingdom
    Posts
    5
    Quote Originally Posted by FloridaJo View Post
    If this is how you plan to learn C, it's going to be a long road.
    I find I learn quicker this way and have learnt other programming languages with the same method.

    Like I said in my original post I am not new to programming and have quite a few years experience with other languages.

    I would of thought the concept is still the same, just need to learn the syntax or is that not the case with C.

    Thanks.

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Kirkkaf View Post
    I find I learn quicker this way and have learnt other programming languages with the same method.

    Like I said in my original post I am not new to programming and have quite a few years experience with other languages.

    I would of thought the concept is still the same, just need to learn the syntax or is that not the case with C.

    Thanks.
    That raises the big question: What other languages do you know?

    If, for example, you've been working mostly in Java or VBasic you are in for one rude awakening as to just how different C is.
    If you've been working in C++ you will have some rudimentary grasp of C's concepts but not necessarily the correct mindset.

    That is to say that C is an animal all it's own and you really should spend some time learning more than simple syntax differences. I've seen others come through here who are fluent in other languages who stumble and balk at C... most often tripping over C's lack of a string type and the requirement that the programmer code their own memory management and error trapping.

    You probably should grab a decent C tutorial and go through it, just to make sure you fully understand the language's correct usage.

  10. #10
    Registered User
    Join Date
    Nov 2011
    Location
    Nottingham, United Kingdom, United Kingdom
    Posts
    5
    Thanks for the explanation Tater I will defiantly take a look at some C tutorials now.

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Glad to help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. About Device Driver Programming And Socket Programming
    By pritesh in forum Linux Programming
    Replies: 6
    Last Post: 01-23-2010, 03:46 AM
  2. Replies: 1
    Last Post: 08-19-2007, 03:55 AM
  3. small programming job VCPP / Object Oriented Programming
    By calgonite in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 01-04-2006, 11:48 PM
  4. Total newb to programming here... Question about the many programming languages. Ty!
    By tsubotakid1 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-05-2003, 10:32 AM