Advertisement
claudiojimenezf

23-08-17

Aug 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. CLASE 22-8-17
  2. fgets(nombrecadena,tamaño,entrada) la entdada puede ser un archivo o un stdin. lee hasta el enter en ese caso
  3.  
  4. gets lee hasta eof
  5.  
  6. fputs
  7.  
  8. puts
  9.  
  10. Comparacion cadena con letra directa sin rango ascii se pone 'X' por ejemplo.
  11.  
  12. fflush detecta el enter y sigue leyendo
  13. se usa combinado con un fgets.
  14.  
  15. toupper convierte mayusculas en minusculas
  16. tolower convierte minusculas en mayusculas
  17.  
  18.  
  19.  
  20. --------------------------------------------
  21. CONVERTIR MINUSCULAS A MAYUSCULAS
  22.  
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <ctype.h>
  26. #define tam 1001
  27. //CUENTA H
  28.  
  29. int main(void)
  30. {
  31. int contadorespacio=0;
  32. int i;
  33. char ar[tam];
  34. fgets(ar,tam,stdin);
  35. for (i=0 ; i < strlen(ar) ; i++)
  36. {
  37. ar[i]=toupper(ar[i]);
  38. }
  39.  
  40. for (i=0 ; i < strlen(ar) ; i++)
  41. {
  42. printf("%c",ar[i]);
  43. }
  44. return 0;
  45. }
  46. ----------------------------------------------------------------------------------
  47. CONVERTIR MAYUSCULAS A MINUSCULAS
  48.  
  49. #include <stdio.h>
  50. #include <string.h>
  51. #include <ctype.h>
  52. #define tam 1001
  53. //CUENTA H
  54.  
  55. int main(void)
  56. {
  57. int contadorespacio=0;
  58. int i;
  59. char ar[tam];
  60. fgets(ar,tam,stdin);
  61. for (i=0 ; i < strlen(ar) ; i++)
  62. {
  63. if((ar[i]>=65)&&(ar[i]<=90)||(ar[i]>=97)&&(ar[i]<=122))
  64. {
  65. contadorespacio=contadorespacio+1;
  66. }
  67. }
  68.  
  69. printf("\n%d",contadorespacio);
  70. return 0;
  71. }
  72.  
  73. ----------------------------------------------------------------------
  74.  
  75. CONTADOR MAYUSCULAS Y MINUSCULAS
  76.  
  77. #include <stdio.h>
  78. #include <string.h>
  79. #define tam 1001
  80. //CUENTA H
  81.  
  82. int main(void)
  83. {
  84. int contadorespacio=0;
  85. int i;
  86. char ar[tam];
  87. fgets(ar,tam,stdin);
  88. /for (i=0 ; i < strlen(ar) ; i++)
  89. {
  90. if((ar[i]>=65)&&(ar[i]<=90)||(ar[i]>=97)&&(ar[i]<=122))
  91. {
  92. contadorespacio=contadorespacio+1;
  93. }
  94. }
  95. printf("\n%d",contadorespacio);
  96. return 0;
  97. }
  98. ----------------------------------------------------------------------
  99. Contador Espacios
  100.  
  101. #include <stdio.h>
  102. #include <string.h>
  103. #define tam 1001
  104. //CUENTA H
  105.  
  106. int main(void)
  107. {
  108. int contadorespacio=0;
  109. int i;
  110. char ar[tam];
  111. fgets(ar,tam,stdin);
  112. for (i=0 ; i < strlen(ar) ; i++)
  113. {
  114. if(isspace(ar[i])==1)
  115. {
  116. contadorespacio=contadorespacio+1;
  117. }
  118. }
  119. printf("\n%d",contadorespacio);
  120. return 0;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement