CS152
Chris Pollett
Sep 1, 2021
For those of you unfamiliar with Unix we next look at some of the most important shell concepts/commands to get started with:
man ls -- would give the Unix manual entry for the ls command. man -k some_keyword -- lists all commands whose description has that keyword.
#include <stdio.h> //for printf statement int main() { printf("Hello World\n"); return 0; }
To compile and run this program:
gcc hello.c -o hello ./hello
int a,b; // declares two int's a and b.
int a[10]; //don't use a variable rather than 10 in ANSI C.
You don't have a class construct. You can pretend --if it helps -- as if everything is declared in the same class. Although, these rules were relaxed somewhat in C99 from ANSI C, you should have all your variable declarations at the start of your functions:
void foo() { int a=1; printf("%d", a); int b; // ANSI C's head explodes }
Similarly, you either need to have a function prototype, or the function itself before the first place you use it -- See next slide.
//the following is okay: char foo(); void bar() { printf("%c", foo()); } char foo( ) { return 'a'; }