Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. /* memtest1a.c*/
  2. #include <stdio.h>
  3. #define SIZE 8
  4. void test(int*, char*);
  5. int main(){
  6. int i = 0;
  7. char buf[SIZE];
  8. printf("Type in 5-20 chars into the text buffer\n"
  9. );
  10. printf("Watch the value of i \n");
  11. printf("it will be corrupted when you exceed %i chars\n",SIZE);
  12. printf("Type \"q\" to exit:\n");
  13. printf("\t| i posn\t| buf start\t| buf end\t| i value\n");
  14. do {
  15. test(&i, buf);
  16. i++;
  17. }while(buf[0] != 'q');
  18. return 0;
  19. }
  20. void test(int *j, char* buf){
  21. scanf("%s",buf);
  22. printf("OK.\t| %u\t| %u\t| %u\t| %d\n",j, buf, &buf[SIZE],*j);
  23. return;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement