Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define nmax 101
  4. void popola(char s[]);
  5. void cambia(char s[], int l);
  6. void stampa(char s[], int l);
  7. int i;
  8.  
  9. main(){
  10.  
  11. int lu,n=nmax;
  12. char str[n];
  13. popola(str);
  14. lu=strlen(str);
  15. cambia(str,lu);
  16. stampa(str,lu);
  17.  
  18. }
  19.  
  20. void popola(char s[]){
  21.  
  22. printf("Inserisci una frase stringa\n");
  23. gets(s);
  24.  
  25. }
  26.  
  27. void cambia(char s[], int l){
  28.  
  29. s[0]=toupper(s[0]);
  30.  
  31. for(i=1;i<l;i++){
  32. if(s[i-1]==' '){
  33. if(isupper(s[i])==0){
  34. s[i]=toupper(s[i]);
  35. }
  36. }else{
  37. s[i]=tolower(s[i]);
  38. }
  39. }
  40.  
  41. }
  42.  
  43. void stampa(char s[], int l){
  44.  
  45. printf("\n\n%s",s);
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement