gpsgiraldi

2024_fun_with_strings

Jun 2nd, 2024 (edited)
993
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     int i,j,n;
  7.     char str0[100],str1[40];
  8.    
  9. //    printf("Set size of string vector: \n");
  10. //    scanf("%d",&n);
  11.     for(j=0;j<40;j++){
  12.         str1[j]='%';
  13.     }
  14.     printf("Let's play with something here...\n");
  15.     printf("... type something so we can start it: \n");
  16.     setbuf(stdin,NULL);
  17.  
  18.     fgets(str0,99,stdin);
  19.     printf("\n... it encompasses %ld positions in the vector, that means, including 'ENTER' function",strlen(str0));
  20.     printf("\n\nYou have typed:\n");
  21.     fputs(str0,stdout);
  22.     for(i=0;i<strlen(str0);i++){
  23.         if(str0[i]=='l'){
  24.             if(str0[i+1]=='e'){
  25.                 if(str0[i+2]=='m'){
  26.                     if(str0[i+3]=='i'){
  27.                         if(str0[i+4]=='n'){
  28.                             if(str0[i+5]=='s'){
  29.                                 if(str0[i+6]=='k'){
  30.                                     if(str0[i+7]=='y'){
  31.                                         printf("Leminsky disse:\num homem com uma dor, é muito mais elegante\ncaminha assim de lado\ncomo se, chegando atrasado...\nandasse mais adiante!");
  32.                                     }
  33.                                 }    
  34.                             }
  35.                         }
  36.                     }
  37.                 }
  38.             }
  39. //            strcat(str1,str0);
  40.         }
  41.     }
  42. //    strcpy(str1,str0);
  43.     setbuf(stdin,NULL);
  44.  
  45.     printf("\n\n... and in the str1 it should also read: \n");
  46.     strcpy(str1,str0);
  47.     for(j=0;j<strlen(str0);j++){
  48.         if(str0[j]=='a'||str0[j]=='e'||str0[j]=='i'||str0[j]=='o'||str0[j]=='u'){
  49.             str1[j-1]='*';
  50.             str1[j]='*';
  51.         }
  52.     }
  53.     fputs(str1,stdout);
  54.     return 0;
  55.    
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment