Guest User

Untitled

a guest
Jun 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. //Function to fund size of string and index spaces
  2. int getSpace(char str[])
  3. {
  4. int n, i, count;
  5. n=strlen(str);
  6. count = 0;
  7. int k[n];
  8. for(i=0; i<n;i++)
  9. {if (str[i]==' '){
  10. count++;
  11. k[count]=i;
  12. printf("\n %d \n",k[count]);
  13. }
  14. }
  15. return(k[n], count);
  16. }
  17.  
  18. //Main for testing getSpace
  19. main()
  20. {
  21.  
  22. char s[]="testing this out and seeing how it goes";
  23.  
  24.  
  25.  
  26. int numSpace = getSpace(s);
  27. printf("\n %d \n",numSpace);
  28.  
  29.  
  30. system ("pause");
  31.  
  32. }
  33.  
  34.  
  35.  
  36. //Separate crap trying to get other to work - still working on
  37. #define N_MAX 1000
  38.  
  39.  
  40.  
  41.  
  42. main()
  43. {
  44.  
  45.  
  46. char s[]="testing this out and seeing how it goes";
  47. char s2[N_MAX];
  48.  
  49. int n, i, j, count;
  50. n=strlen(s);
  51. count = 0;
  52. for(i=0; i<n;i++)
  53. {if (s[i]==' '){
  54. count++;}
  55.  
  56. j=0;
  57. for(i=0; i<n;i++)
  58. {
  59. for (j=0;j<n;j++)
  60. {
  61. s2[j][i]=s[i];
  62.  
  63. if (s[i]==' '){
  64. j++;
  65. }
  66. }
  67. }
  68. }
  69.  
  70. system ("pause");
  71.  
  72. }
Add Comment
Please, Sign In to add comment