Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define DIM 52
- void getString( char [] );
- int main()
- {
- char s[DIM];
- printf("Please insert a string ( MAX %d characters ) \n", DIM);
- getString(s);
- printf("STRING : %s\n", s);
- /*system("PAUSE"); */
- return 0;
- }
- void getString( char s[] )
- {
- char c;
- int i = 0;
- while( ( c = getchar() ) != '\n' && i < DIM )
- {
- s[i] = c;
- i++;
- }
- s[i] = '\0';
- }
Add Comment
Please, Sign In to add comment