Thread: help me understand string

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    18

    help me understand string

    I have great problems regarding string. Can anyone give me any good sites that I can surf to help me understand string. I'm confused. Whats the difference between printf, scanf, gets, puts, fgets, fputs, getc, putc, fflush and how should i know when to use which one? I'm a begginer and I'm totally lost here.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Here's a tutorial for character strings (char), but it's for C++. However, since it's char arrays, it suits for C, as well:
    http://www.cprogramming.com/tutorial/lesson9.html

    And forget gets. You should never use it.
    Printf is a function that prints a "formatted" string to the screen. Having a look at printf's documentation may help.
    Puts prints a string to the screen.
    Fgets reads a string from the user.
    FPuts writes a string to a file.
    Getc reads a character from the user.
    Putc prints a character to the screen.
    And fflush empties the output buffer and makes sure any data there goes to its destination. Typically used to force data to the screen when printing to make sure the user sees the text on the screen or in files when you need the data to be written to disk (otherwise it can potentially stay in memory). Never flush stdin.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed