View Single Post
Join Date: Jan 2008
Posts: 6
Reputation: Matt You is an unknown quantity at this point 
Solved Threads: 0
Matt You Matt You is offline Offline
Newbie Poster

Re: scanning char array for \0 problem

 
0
  #3
Jan 22nd, 2008
here ya go:
  1. #include <stdio.h>
  2.  
  3. int dummy;
  4.  
  5. int stringSplitter(char arrayToSplit[], int arraySize);
  6.  
  7. int main()
  8. {
  9. char userString[20];
  10.  
  11. printf("Enter 3 numbers, seperated by spaces: ");
  12. scanf( "%s", userString);
  13.  
  14. stringSplitter(userString, 20);
  15.  
  16. scanf("%d", dummy);
  17. }
  18.  
  19. int stringSplitter(char arrayToSplit[], int arraySize)
  20. {
  21. unsigned int i;
  22.  
  23. for( i=0 ; arrayToSplit[i]!='\0' ; i++ )
  24. {
  25. printf("%c", arrayToSplit[i]);
  26.  
  27. }
  28.  
  29. }
Reply With Quote