Difference between revisions of "GNU C Programming Notes"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
m
(So you want to program GNU C in Debian/Ubuntu/Mint ?)
Line 3: Line 3:
 
== So you want to program GNU C in Debian/Ubuntu/Mint ? ==
 
== So you want to program GNU C in Debian/Ubuntu/Mint ? ==
 
Install the Development Libraries and Header Files which contains the symlinks, headers, and object files needed to compile and link programs which use the standard C library.  
 
Install the Development Libraries and Header Files which contains the symlinks, headers, and object files needed to compile and link programs which use the standard C library.  
 
 
  sudo apt-get install libc6-dev
 
  sudo apt-get install libc6-dev
 +
 +
Without them you will get: fatal error: stdio.h: No such file or directory when the compile is seeking stdio.h
 +
 +
The libraries of “stdio” stands for “standard input/output, the most basic libraries for getting the input from the keyboard and output result text to the display or whatever.
  
 
== getchar() and loop control ==
 
== getchar() and loop control ==

Revision as of 18:09, 12 January 2020

Text Notes Document for Gnu C Programming

So you want to program GNU C in Debian/Ubuntu/Mint ?

Install the Development Libraries and Header Files which contains the symlinks, headers, and object files needed to compile and link programs which use the standard C library.

sudo apt-get install libc6-dev

Without them you will get: fatal error: stdio.h: No such file or directory when the compile is seeking stdio.h

The libraries of “stdio” stands for “standard input/output, the most basic libraries for getting the input from the keyboard and output result text to the display or whatever.

getchar() and loop control

C program that needs to attend the user input without blocking a loop depends on which environment you're coding: raw-C for the glass-tty, curses/termcap, X, KDE, Gnome, etc.

the ncurses function halfdelay()

getchar() example

#include <stdio.h>

#define EOL 10
#define ESC 27

main() {

  char c = 'X';

  while (c != ESC) {

    int cnt;
    cnt++;
    printf("iteration of test %d", cnt);

    c = getchar();

  }
  return 0;

}

getputchar() example

#include <stdio.h>

main() {
       int c;
       c=getchar(); /*declare c to getchar() for character inputs*/
       while(c != EOF){
       putchar(c);
       c=getchar();
       }
}

==

References

  • Introduction to ANSI C (on linux)
http://www.linuxuniversity.org/dev_track/c_class/