+ All Categories
Home > Technology > C-langage

C-langage

Date post: 15-Jan-2015
Category:
Upload: hiramatsu-ryosuke
View: 535 times
Download: 1 times
Share this document with a friend
Description:
 
Popular Tags:
33
C-LANG
Transcript
  • 1. C-LANG

2. 1. cc chap1_1.c a.out 2. cc chap1_1.c -o chap1_1 chap1_1 3. 1. syntax error - 2. undeclared - 3. parse error - {} 4. int8 x = 066616 x = 0x6F15 5. x++, x1++xx1, 6. & : | : ^ : ~ : > : () 7. ? 1 : 2 1 2 8. int x[30]; int x[30] = {10, 20, 30, 328}; int x[] = {10, 20, 30, 328}; int x[]; Error! 9. char name[20]; name[0]=S; name[1]=u; name[2]=..... char name[20] = {S, u, z, u, k, i, 0}; printf(%sn, name); char name[20] = Suzuki; !! 10. scanf(%d, x);scanf(%s, str[0]);scanfOK. 11. 2 int data[3][5] ={ {3,4,8,6,4}, {6,4,2,2,0}, ...} 5 3 12. ! ! ! 13. int *pa;pa = &a; a printf(%pn, pa); a printf(%dn, *pa); a *pa += 10; a 10 14. - r w FILE *fp;a r+ w+ fp = fopen(le.txt, r); a+ if( (fp = fopen(le.txt, r)) == NULL ){/* */ } 15. - while( (c=getc(fp)) != EOF ) printf(%c, c);while( fscanf(fp, %s%d, city, value) != EOF ) printf(%s -> %dn, city, value);! 16. - for(i=0; name[i] != (c=getc(fp)) != EOF )printf(%c, c);fprintf(fp, %s%d, city, value);! 17. 1. char *[] = {1, 2, ... }; 18. 2. char *p, **dp;p &c;dp = &p;printf(%pn, *dp);C printf(%dn, **dp); C 19. int main(int argc, char *argv[]){ ..... ..... ..... return 0; } 20. - make - - (.h)- #include header.h- extern int x; // #include 21. Score *p, *top;if( (p = (Score *)malloc(sizeof(Score) * size)) ==NULL){ /* */}top = p; ///* p */free(top); //! 22. -char *str[] = {Hello, Good-bye, OK};- printf(%sn, str[0]); printf(%sn, str[1]); printf(%sn, str[0]); 23. ()SIGINT : SIGALRM : alarmSIGSEGV : signal(SIGINT, func); func() 24. fork() pid = fork(); fork() if( pid != 0){ // } else { // } 25. wait()exit()wait() pid = fork(); if( pid != 0){ // exit() wait(&status); // } else { // exit(status); // } 26. exec(), execvp() char *argv[] = {ls, -a, NULL}; execvp(ls, argv); execvp() 27. - - FIFO- 28. - - fd[0] : - fd[1] : - pipe(fd)fd[0] fd[0] fd[0] fd[1] 29. - if( pipe(fd)== -1){perror(pipe);}if( (len=write(fd[1], buf, strlen(buf)+1))==NULL){ perror(write); }if( (len=read(fd[0], buf, strlen(buf)))==NULL){ perror(read); } 30. - FIFO- - mknode(), mkfo()- FIFO 31. FIFO - if( mkfo(myFifo, 0666) == -1){make perror(mkfo); } if( (fd=open(myfo, O_WRONLY)) == -1){openperror(open);} if( write(fd, buf, sizeof(buf)))==-1){write!perror(write);} 32. FIFO - if( (fd=open(myfo, O_RDONLY)) == -1){open perror(open); }if( ret= read(fd, buf, sizeof(buf)))==-1){read!perror(write); } 33. - - -


Recommended