Guest User

Untitled

a guest
Dec 14th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. int n;
  2. scanf("%d", &n);
  3. char *a[n];
  4. a[n] = malloc(n*sizeof(char));
  5.  
  6. int i;
  7. int j;
  8.  
  9. for (i = 0; i < n; i++) {
  10.  
  11. a[i] = malloc(sizeof(char));
  12.  
  13. }
  14.  
  15.  
  16. for ( i = 0; i < n; i++) {
  17.  
  18. printf("write the words: ");
  19. scanf("%s", a[i]);
  20.  
  21. }
  22.  
  23. //till this point everything works
  24.  
  25. //now I need to print each character of the strings
  26.  
  27. for ( i = 0; i < n; i++) {
  28.  
  29. for ( j = 0; j < strlen(a[i][j]); j++) {
  30.  
  31. printf("%s", a[i][j]);
  32.  
  33. }
  34.  
  35. }
Add Comment
Please, Sign In to add comment