Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. int main()
  2. {
  3. // Expand set array size as needed
  4. int arraySize = 17380;
  5. char *input = (char*) malloc(sizeof(char) * arraySize);
  6. char inputChar;
  7. int arrayIndex = 0;
  8.  
  9. while (1)
  10. {
  11. inputChar = getchar();
  12.  
  13. // break if end of file
  14. if (inputChar == EOF)
  15. break;
  16.  
  17. // store char in array
  18. inputArray[arrayIndex] = inputChar;
  19. arrayIndex++;
  20.  
  21. // read char from stdin
  22. inputChar = getchar();
  23. printf("Input char:");
  24. putchar(inputchar);
  25. printf("\n");
  26.  
  27. printf("The array contents are:\n");
  28. for(int i = 0; i < arrayIndex; i++)
  29. {
  30. printf("The array index is: %d\n", arrayIndex);
  31. printf("%c", inputArray[i]);
  32. printf( "\n" );
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement