Web Page - http://www.cs.tau.ac.il/~efif/courses/Software1_Spring_03
int getchar(void); |
int putchar(int ch); |
main() { int c; c = getchar(); while(c != EOF) { putchar(c); c = getchar(); } return 0; } |
while((c = getchar()) != EOF) putchar(c); |
(c = getchar()) |
#include <stdio.h> /*! getline() reads one line from standard input and copies it to line array * (but no more than max chars). * It does not place the terminating \n in line array. * Returns line length, or 0 for empty line, or EOF for end-of-file. */ int getline(char line[], int max) { int nch = 0; int c; max = max - 1; /* leave room for '\0' */ while ((c = getchar()) != EOF) { if (c == '\n') break; if (nch < max) { line[nch] = c; nch = nch + 1; } } if (c == EOF && nch == 0) return EOF; line[nch] = '\0'; return nch; } |
Nova 1% |
hostname -f |
#include <stdio.h> #include <ctype.h> int main() { int c; if ((c = getchar()) == EOF) return 0; putchar(toupper(c)); while ((c = getchar()) != EOF) putchar(c); return 0; } |
~/bin/
directory
~/.cshrc
file
if ( $?prompt ) then if ( -o /bin/su ) then set prompt="`hostname -s | ~/bin/capitalize` \!# " else set prompt="`hostname -s | ~/bin/capitalize` \!% " endif endif |
#include <stdio.h> /*! * constants */ #define WIDTH 60 #define HEIGHT 60 #define CENTER_X 30 #define CENTER_Y 30 #define R 20 #define THRESHOLD R /*! * main */ int main() { int x, y, val; for (y = 0; y < HEIGHT; y++) { for (x = 0; x < WIDTH; x++) { val = (y - CENTER_Y) * (y - CENTER_Y) + (x - CENTER_X) * (x - CENTER_X) - R * R; if (abs(val) < THRESHOLD) printf("%c", '#'); else printf(" "); } printf("\n"); } return 0; } |