Sunteți pe pagina 1din 24

ESCUELA POLITECNICA NACIONAL Formatted: Font: Bold, Font color: Text 1, Text Outline,

Shadow
Formatted: Font: 16 pt, Bold, Font color: Text 1, Text
PROGRAMACION EN ANSI C Outline, Shadow
Formatted: Centered
Formatted: Left: 0.79", Right: 0.88", Top: (Dotted,
Auto, 0.5 pt Line width), Bottom: (Dotted, Auto, 0.5 pt
Line width), Left: (Dotted, Auto, 0.5 pt Line width),
Right: (Dotted, Auto, 0.5 pt Line width)
Formatted: Centered
Formatted: Font: 16 pt

Formatted: Font: 18 pt, Bold


Librerías Estándar del Lenguaje ANSI C
Realizado por: José Jefferson Cueva Prieto Formatted: Font: 14 pt, Bold
Formatted: Indent: First line: 0.49"
Asignatura: Programación Formatted: Font: Bold

Grupo: Gr1 Formatted: Font: 14 pt


Formatted: Font: 14 pt
Facultad: Ing. Electrica y Electrónica Formatted: Font: 14 pt, Bold

Carrera: Ing. Electrónica y Redes Formatted: Font: 14 pt


Formatted: Font: 14 pt
Formatted: Font: 14 pt, Bold
Formatted: Font: 14 pt
Formatted: Font: 14 pt
QUITO 27 DE ENERO DEL 2018 Formatted: Font: 14 pt, Bold
Formatted: Font: 14 pt
Formatted: Font: 14 pt
Objetivos
Determinación de la funcionalidad de cada una de las librerías descritas en este presente informe. (
<ctype.h> || <math.h> ||<time.h> || <string.h> )

Detallar las funciones con valores de retorno de 0 y 1.

Demostrar la aplicación de estas librerías con operaciones que se utiliza con frecuencia.

Concepto
Las funciones estándar o predefinidas se denominan funciones pertenecientes a la biblioteca
estándar que se dividen en grupos; todas las funciones que pertenecen al mismo grupo se
declaran en el mismo archivo de cabecera
En las versiones de c se ofrece una biblioteca estándar de funciones en tiempo de ejecución que
dan soporte eficaz más accesible a operaciones utilizadas con frecuencia sin necesidad de volver
a escribir código para cumplir las mismas funciones de estas librerías.
FUNCIONES NUMERICAS <math.h>
Virtualmente cualquier operación aritmética es posible en unn programa C. Las funciones
disponibles son las siguientes
1. Matemáticas
2. Trigonométricas
3. Logarítmicas
4. Exponenciales
La mayoría de funciones numéricas están en el archivo de cabecera Manth.h
Funciones matemáticas
ceil(x) Redondea al entero másentero más cercano.
fabs(x) Devuelve el valor absoluto de x.
floor(x) Redondea por defecto al entero más próximo.
fmod(x,y) Calcula el resto en coma flotante para la división x/y de modo que x=i*y +f, donde
i es un entero , f tiene el mismo signo que x y el valor absoluto de f es menor que el valor
absoluto de y
pow(x,y) Calcula x elevado a la potencia y Si x es menor que o igual a cero, y debe ser un
entero, Si x es igual a cero, y no puede ser negativo .
pow10(x) Calcula 10 elevado a la potencia x(IO); x debe ser de tipo entero.
sqrt(x) Devuelve la raíz cuadrada de x; x debe ser mayor o igual a cero.

Funciones trigonométricas
acos(x) Calcula el arco coseno del argumento x. El argumento x debe estar entre -1 y 1.
asin(x) Calcula el arco seno del argumento x. El argumento x debe estar entre -1 y 1.
atan(x) Calcula el arco tangente del argumento x.
atan2 (x,y) Calcula el arco tangente de x dividido por y.
cos(x) Calcula el coseno delcoseno del anguloángulo x; x se expresa en radianes.
sin(x) Calcula el seno del anguloángulo x; x se expresa en radianes.
tan(x) Devuelve la tangente del anguloángulo x; x se expresa en radianes.

Funciones logarítmicas y exponenciales


exp(x), expl(x) Calcula el exponencial e, donde edonde e es la base de logarítmicos naturales de
valor 2.718282.
Una variable de esta función es expl, que calcula e utilizando un valor long doublé (largo doble).
log(x), longl(x) La función log calcula el logaritmo natural del argumento x y longl(x) calcula el
logaritmo natural del argumento x de valor longvalor long doublé(doublé (Largo doble).
NOTA: Antes de copiar el código para llevarlo al compilador se debe sombrear y quitar el
enumerado (Esto evitara que se copie el código con la enumeración).

1. //Funciones Numéricas math.h junto a stdio.h


2. #include<stdio.h>
3. #include<math.h>//libreria a utilizar
4. #include<stdlib.h>
5. /*
6. matematicas trigonometricas logaritmicas exponenciales aleatorias*/
7.
8. int vrpeticion(void){
9. int auxsld;
10. do{
11.
12. printf("\n1.Repetir programa");
13. printf("\n2.Salir del programa\n");
14. scanf("%d",&auxsld);
15. if(auxsld!=1&&auxsld!=2){
16. printf("\nOpcion incorrecta!");
17. printf("\a");
18. system("cls");
19. }
20. }while(auxsld!=1&&auxsld!=2);
21. system("cls");// system("clear"); linux - Formatted: English (United States)
- system("cls"); windows
22. return auxsld; Field Code Changed
23. } Formatted: English (United States)
24. int main(void){
25. int opc,auxsld,operadorsalida; Formatted: English (United States)
26. double x1, y;
Formatted ...
Field Code Changed ...
Formatted ...
27. float x,y1;
28. system("color F0"); Formatted ...
29. do{
Formatted ...
30. printf("\t\t\t\t\t\t<math.h>\n");
31. x=0; Formatted ...
32. printf("--FUNCIONES MATEMATICAS--\n");
33. printf("\t\t\t1.Funcion ceil(x)\n"); Formatted ...
34. printf("\t\t\t2.Funcion fabs(x)\n"); Formatted ...
35. printf("\t\t\t3.Funcion floor(x)\n");
36. printf("\t\t\t4.Funcion fmod(x,y)\n"); Field Code Changed ...
37. printf("\t\t\t5.Funcion pow(x,y)\n"); Field Code Changed ...
38. printf("\t\t\t6.Funcion pow10(x)\n");
39. printf("\t\t\t7.Funcion sqrt(x)\n\n"); Formatted ...
40. printf("--FUNCIONES TRIGONOMETRICAS--\n"); Formatted ...
41. printf("Nota:la expresion de x es radianes, para poner en
grados;\n"); Formatted ...
42. printf("se necesita multiplicar por pi/180 pi=3.14159\n"); Field Code Changed
43. printf("\t\t\t8.Funcion acos(x)\n"); ...
44. printf("\t\t\t9.Funcion asin(x)\n"); Formatted ...
45. printf("\t\t\t10.Funcion atan(x)\n");
Formatted ...
46. printf("\t\t\t11.Funcion atan2(x,y)\n");
47. printf("\t\t\t12.Funcion cos(x)\n"); Field Code Changed ...
48. printf("\t\t\t13.Funcion sen(x)\n");
Formatted ...
49. printf("\t\t\t14.Funcion tan(x)\n\n");
50. printf("--FUNCIONES LOGARITMICAS Y EXPONENCIALES--\n"); Formatted ...
51. printf("\t\t\t15.Funcion exp(x) y expl(x)\n");
52. printf("\t\t\t16.Funcion log(x) y logl(x)\n"); Field Code Changed ...
53. printf("\t\t\t17.Funcion log10(x) y log101(x)\n\n"); Formatted ...
54. printf("ELIJA UNA OPCION: ");
55. scanf("%d",&opc); Formatted ...
56. if(opc==1){ Formatted ...
57. printf("\nIngrese un numero ENTERO || DECIMAL: ");
58. scanf("%f",&x); Field Code Changed ...
59. printf( "ceil( %f ) = %f\n", x, ceil(x) ); Formatted ...
60. auxsld=vrpeticion();
61. } Formatted ...
62. else if(opc==2){ Field Code Changed ...
63. printf("\nIngrese un numero ENTERO || DECIMAL --
>(negativo): "); Formatted ...
64. scanf("%f",&x); Formatted
65. printf( "fabs( %f ) = %.2f\n", x, fabs(x) ); ...
66. auxsld=vrpeticion(); Formatted ...
67. }
Formatted ...
68. else if(opc==3){
69. printf("\nIngrese un numero ENTERO || DECIMAL Formatted ...
(redondea al entero proximo): ");
Field Code Changed ...
70. scanf("%f",&x);
71. printf( "floor( %f ) = %.2f\n", x, floor(x) ); Formatted ...
72. auxsld=vrpeticion();
Formatted ...
73. }
74. else if(opc==4){ Field Code Changed ...
75. printf("\nIngrese un numero ENTERO || DECIMAL-->
(valor de x): "); Formatted ...
76. scanf("%lf",&x1); Field Code Changed ...
77. printf("\nIngrese un numero ENTERO || DECIMAL-->
(valor de y): "); Formatted ...
78. scanf("%lf",&y); Formatted ...
79. printf( "fmod( %lf,%lf ) =
%.2lf\n", x1,y, fmod(x1,y) ); Field Code Changed ...
80. auxsld=vrpeticion(); Formatted ...
81. }
Formatted ...
82. else if(opc==5){
83. printf("\nIngrese un numero ENTERO || DECIMAL --
>(base): ");
84. scanf("%f",&x);
85. printf("\nIngrese un numero ENTERO || DECIMAL --
>(exponente): ");
86. scanf("%f",&y1);
87. printf( "pow( %.2f,%.2f) =
%.2f\n", x,y1, pow(x,y1) );
88. auxsld=vrpeticion();
89. }
90. else if(opc==6){
91. printf("\nIngrese un numero ENTERO || DECIMAL --
>(10^exponente): ");
92. scanf("%f",&x);
93. printf("Funcionamiento en (IO)\n");
94. // printf( "pow10( %.2f ) = %.2f\n", x, pow10(x) );
95. auxsld=vrpeticion();
96. }
97. else if(opc==7){
98. printf("\nIngrese un numero ENTERO || DECIMAL --
>(calculo de raiz cuadrada): ");
99. scanf("%f",&x);
100. //printf("Funcionamiento en (IO)\n");
101. printf( "sqrt( %.2f ) = %.2f\n", x, sqrt(x) ); Formatted: English (United States)
102. auxsld=vrpeticion();
103. } Formatted: English (United States)
104. else if(opc==8){ Field Code Changed
105. printf("\nIngrese un numero ENTERO || DECIMAL -->(x
entre -1 y 1): "); Formatted: English (United States)
106. scanf("%f",&x);
Field Code Changed
107. //printf("Funcionamiento en (IO)\n");
108. printf( "acos( %.2f ) = %.2f\n", x, acos(x) ); Formatted: English (United States)
109. auxsld=vrpeticion();
110. }
111. else if(opc==9){
112. printf("\nIngrese un numero ENTERO || DECIMAL -->(x
entre -1 y 1): ");
113. scanf("%f",&x);
114. //printf("Funcionamiento en (IO)\n");
115. printf( "asin( %.2f ) = %.2f\n", x, asin(x) ); Formatted: English (United States)
116. auxsld=vrpeticion();
117. } Formatted: English (United States)
118. else if(opc==10){ Field Code Changed
119. printf("\nIngrese un numero ENTERO || DECIMAL (en
radianes): "); Formatted: English (United States)
120. scanf("%f",&x);
Formatted: English (United States)
121. //printf("Funcionamiento en (IO)\n");
122. printf( "atan( %.2f ) = %.2f\n", x, atan(x) ); Field Code Changed
123. auxsld=vrpeticion();
124. }
125. else if(opc==11){
126. printf("\nIngrese un numero ENTERO || DECIMAL --
>(x) nota:x/y : ");
127. scanf("%f",&x);
128. printf("\nIngrese un numero ENTERO || DECIMAL --
>(y): ");
129. scanf("%f",&y1);
130. printf( "atan2( %.2f,%.2f) =
%.2f\n", x,y1, atan2(x,y1) );
131. auxsld=vrpeticion();
132. }
133. else if(opc==12){
134. printf("\nIngrese un numero ENTERO || DECIMAL (en
radianes): ");
135. scanf("%f",&x);
136. //printf("Funcionamiento en (IO)\n");
137. printf( "cos( %.2f ) = %.2f\n", x, cos(x) );
138. auxsld=vrpeticion();
139. }
140. else if(opc==13){
141. printf("\nIngrese un numero ENTERO || DECIMAL (en
radianes): ");
142. scanf("%f",&x);
143. //printf("Funcionamiento en (IO)\n");
144. printf( "sin( %.2f ) = %.2f\n", x, sin(x) );
145. auxsld=vrpeticion();
146. }
147. else if(opc==14){
148. printf("\nIngrese un numero ENTERO || DECIMAL (en
radianes): ");
149. scanf("%f",&x);
150. //printf("Funcionamiento en (IO)\n");
151. printf( "tan( %.2f ) = %.2f\n", x, tan(x) );
152. auxsld=vrpeticion();
153. }
154. else if(opc==15){
155. printf("\nIngrese un numero ENTERO || DECIMAL : ");
156. scanf("%f",&x);
157. //printf("Funcionamiento en (IO)\n");
158. printf( "exp( %.2f ) = %.2f\n", x, exp(x) ); Formatted: English (United States)
159. auxsld=vrpeticion();
160. } Field Code Changed
161. else if(opc==16){ Formatted: English (United States)
162. printf("\nIngrese un numero ENTERO || DECIMAL : ");
163. scanf("%f",&x); Formatted: English (United States)
164. //printf("Funcionamiento en (IO)\n");
Field Code Changed
165. printf( "log( %.2f ) = %.2f\n", x, log(x) );
166. auxsld=vrpeticion(); Formatted: English (United States)
167. }
Formatted: English (United States)
168. else if(opc==17){
169. printf("\nIngrese un numero ENTERO || DECIMAL : "); Formatted: English (United States)
170. scanf("%f",&x);
Field Code Changed
171. //printf("Funcionamiento en (IO)\n");
172. printf( "log10( %.2f ) = %.2f\n", x, log10(x) ); Formatted: English (United States)
173. auxsld=vrpeticion();
174. } Formatted: English (United States)
175. else if(opc<1||opc>17){ Field Code Changed
176. system("cls");
177. printf("\nOpcion incorrecta!\n\n"); Field Code Changed
178. printf("\a"); Formatted: English (United States)
179. auxsld=1;
180. Formatted: English (United States)
181. } Field Code Changed
182. }while(auxsld==1);
183. printf("\a"); Formatted: English (United States)
184. Formatted: English (United States)
185. return 0;
186. }
FUNCIONES CADENAS DE CARACTERES <string.h>
Funciones de copiado
mencpy Copiar bloque de memoria.
memmove Mover bloque de memoria.
strcpy Copiar cadena.
strncpy Copiar caracteres de la cadena.
Funciones de concatenación
strcat Cadenas de concatenación.
strncat Anexar caracteres de cadena.
Funciones de comparación
memcmp Compara dos bloques de memoria.
strcmp Comparar dos cadenas.
strcoll Compare dos cadenas usando locale.

strncmp Compara los caracteres decaracteres de dos cuerdas.


strxfrm Transformar cadena usando locale.
Funciones de buscado
memchr Ubicar personaje en bloque de memoria.
strchr Ubicar la primera aparición de carácter en cadena.
strcspn Obtener span hasta personaje en string.
strpbrk Ubicar caracteres en cadena.
strrchr Ubica la última aparición de carácter en una cadena .cadena.
strspn Obtiene span de conjunto de caracteres en cadena .cadena.
strstr Ubicar subcadena .subcadena.
strtok Separar cadena en tokens.
Otras funciones
menset Rellene el bloque de memoria.
strerror Obtener puntero a cadena de mensaje de error.
strlen Obtener longitud de cadena.
NOTA: Antes de copiar el código para llevarlo al compilador se debe sombrear y quitar el
enumerado (Esto evitara que se copie el código con la enumeración).

1. //funciones de string.h
2. #include<stdio.h>
3. #include<string.h>//libreria a utilizar
4. #include<stdlib.h>
5. /**/
6.
7. struct {
8. char name[40];
9. int age;
10. } person, person_copy;
11. int vrpeticion(void){
12. int auxsld;
13. do{
14.
15. printf("\n1.Repetir programa");
16. printf("\n2.Salir del programa\n");
17. scanf("%d",&auxsld);
18. if(auxsld!=1&&auxsld!=2){
19. printf("\nOpcion incorrecta!");
20. printf("\a");
21. system("cls");
22. }
23. }while(auxsld!=1&&auxsld!=2);
24. system("cls");// system("clear"); linux - Formatted: English (United States)
- system("cls"); windows
25. return auxsld; Field Code Changed
26. } Formatted: English (United States)
27. int main(void){ // variables creadas en ordena impresion de lista
28. int opc,auxsld,operadorsalida; Formatted: English (United States)
29.
30. char * pch;
31. char str2[] = "Ejemplo string";
32.
33. char buffer1[] = "DWgaOtP12df0";
34. char buffer2[] = "DWGAOTP12DF0";
35. int n;
36.
37. char myname[] = "Quito capital de Ecuador";
38.
39. char str[] = "manzana can be very useful......";
40.
41. char str1[] = "almenos Cada programador debe saberme!";
42.
43. char str4[80];
44.
45. char str5[] = "Este es un ejemplo de string";
46. char * pch234;
47.
48. char key[] = "gta5";
49. char buffer[80];
50.
51. char key2[] = "pera";
52. char buffer23[80];
53.
54. char str13[]="ejemplo string";
55. char str23[40];
56. char str33[40];
57.
58. char str210[] = "fcba73";
59. char keys2[] = "1234567890";
60. int i245;
61.
62. FILE * pFile;
63.
64. char szInput[256];
65.
66. char str134[20];
67. char str234[20];
68.
69. char str45[][5] = { "R2D2" , "C3PO" , "R2A6" };
70. int n45;
71.
72. char str114[]= "ser o no ser perro";
73. char str214[40];
74. char str314[40];
75.
76. char str56[] = "Este es un ejemplo de string";
77. char key56[] = "aeiou";
78. char * pch56;
79.
80. char str78[] = "Este es un ejemplo de string";
81. char * pch78;
82.
83. int i89;
84. char strtext[] = "129th";
85. char cset89[] = "1234567890"; Formatted: English (United States)
86.
87. char str00[] ="La ESCUELA POLITECNICA NACIONAL es la mejor de Field Code Changed
Quito"; Formatted: English (United States)
88. char * pch00;
89. Formatted: English (United States)
90. char str01[] ="- Aprediendo programacion hackeare la NASA";
Formatted: English (United States)
91. char * pch01;
92. Field Code Changed
93. char s2011[] = "abcdefg";
Formatted: English (United States)
94. char s1011[7];
95. int i011; Formatted: English (United States)
96.
Field Code Changed
97.
98. system("color F0"); Formatted: English (United States)
99. do{
100. printf("\t\t\t\t\t\t<string.h>\n"); Formatted: English (United States)
101. Field Code Changed
102. printf("\t\t\t1.Funcion memchr\n");
103. printf("\t\t\t2.Funcion memcmp\n"); Formatted: English (United States)
104. printf("\t\t\t3.Funcion memcpy\n"); Formatted: English (United States)
105. printf("\t\t\t4.Funcion memmove\n");
106. printf("\t\t\t5.Funcion memset\n"); Formatted: English (United States)
107. printf("\t\t\t6.Funcion strcat\n"); Formatted: English (United States)
108. printf("\t\t\t7.Funcion strchr\n");
Field Code Changed
Formatted ...
Field Code Changed ...
Formatted ...
Field Code Changed ...
109. printf("\t\t\t8.Funcion strcmp\n");
Field Code Changed ...
110. printf("\t\t\t9.Funcion strcoll\n");
111. printf("\t\t\t10.Funcion strcpy\n"); Formatted ...
112. printf("\t\t\t11.Funcion strcspn\n");
Formatted ...
113. printf("\t\t\t12.Funcion strerror\n");
114. printf("\t\t\t13.Funcion strlen\n"); Field Code Changed ...
115. printf("\t\t\t14.Funcion strncat\n");
116. printf("\t\t\t15.Funcion strncmp\n"); Field Code Changed ...
117. printf("\t\t\t16.Funcion strncpy\n"); Formatted ...
118. printf("\t\t\t17.Funcion strpbrk\n");
119. printf("\t\t\t18.Funcion strrchr\n"); Field Code Changed ...
120. printf("\t\t\t19.Funcion strspn\n"); Formatted ...
121. printf("\t\t\t20.Funcion strstr\n");
122. printf("\t\t\t21.Funcion strtok\n"); Field Code Changed ...
123. printf("\t\t\t22.Funcion strxfrm\n"); Formatted ...
124. printf("ELIJA UNA OPCION: ");
125. scanf("%d",&opc); Formatted ...
126. if(opc==1){ Field Code Changed ...
127. printf("Ejemplo string\n");
128. pch = (char*) memchr (str2, 'p', strlen(str2)); Field Code Changed ...
129. if (pch!=NULL) Formatted
130. printf ("'p' se encontro position %d.\n", pch-str2+1); ...
131. else Field Code Changed ...
132. printf ("'p' no se encontro.\n");
Formatted ...
133.
134. auxsld=vrpeticion(); Field Code Changed ...
135. }
Formatted ...
136. else if(opc==2){
137. n=memcmp ( buffer1, buffer2, sizeof(buffer1) ); Field Code Changed ...
138. printf(" DWgaOtP12df0 comparacion peso bytes DWGAOTP12DF0\n");
139. if (n>0) printf ("'%s' es mayor que '%s'.\n",buffer1,buffer2); Formatted ...
140. else if (n<0) printf ("'%s' es menos que Field Code Changed ...
'%s'.\n",buffer1,buffer2);
141. else printf ("'%s' es lo mismo que '%s'.\n",buffer1,buffer2); Formatted ...
142. Field Code Changed ...
143. auxsld=vrpeticion();
144. } Formatted ...
145. else if(opc==3){ Field Code Changed ...
146. /* using memcpy to copy string: */
147. memcpy ( person.name, myname, strlen(myname)+1 ); Formatted ...
148. person.age = 24; Formatted ...
149.
150. /* using memcpy to copy structure: */ Field Code Changed ...
151. memcpy ( &person_copy, &person, sizeof(person) ); Formatted
152. ...
153. printf ("person_copia: %s, Field Code Changed ...
%d \n", person_copy.name, person_copy.age );
Formatted ...
154.
155. auxsld=vrpeticion(); Formatted ...
156. }
Field Code Changed ...
157. else if(opc==4){
158. printf("manzana can be very useful......\n"); Formatted ...
159. memmove (str+20,str+15,11);
160. puts (str); Formatted ...
161. Field Code Changed ...
162. auxsld=vrpeticion();
163. } Formatted ...
164. else if(opc==5){ Field Code Changed ...
165.
166. printf("almenos Cada programador debe saberme!\n"); Formatted ...
167. memset (str1,'-',7); Field Code Changed ...
Formatted ...
Field Code Changed ...
Formatted ...
Field Code Changed ...
Formatted ...
Formatted ...
Field Code Changed ...
Formatted ...
168. puts (str1);
169. auxsld=vrpeticion();
170. }
171. else if(opc==6){
172.
173. strcpy (str4,"las ");
174. strcat (str4,"mejores ");
175. strcat (str4,"son ");
176. strcat (str4,"las ");
177. strcat (str4,"poliburgues.");
178. printf("\nUnion de cadenas\n\n");
179. printf("las\nmejores\nson\nlas\npoliburgues\n\n");
180. puts (str4);
181. auxsld=vrpeticion();
182. }
183. else if(opc==7){
184.
185. printf (" \"%s\"...\n",str5);
186. pch234=strchr(str5,'s');
187. printf("\nBuscando el caracter 's'\n");
188. while (pch234!=NULL)
189. {
190. printf ("encontrado en puesto %d\n",pch234-str5+1);
191. pch234=strchr(pch234+1,'s');
192. }
193. auxsld=vrpeticion();
194. }
195. else if(opc==8){
196. do {
197. printf ("Cual es mi juego favorito?(rpt: gta5) ");
198. fflush (stdout);
199. scanf ("%79s",buffer);
200. } while (strcmp (key,buffer) != 0);
201. puts ("Respuesta correcta!");
202.
203. auxsld=vrpeticion();
204. }
205. else if(opc==9){
206. do {
207. printf ("Cual es mi fruta favorita?(rpt: pera) ");
208. fflush (stdout);
209. scanf ("%79s",buffer23);
210. } while (strcoll(key2,buffer23) != 0);
211. puts ("Respuesta correcta!");
212.
213. auxsld=vrpeticion();
214. }
215. else if(opc==10){
216.
217. strcpy (str23,str13);
218. strcpy (str33,"copia exitosa");
219. printf ("str1: %s\nstr2: %s\nstr3: %s\n",str13,str23,str33); Formatted: English (United States)
220. auxsld=vrpeticion();
221. } Field Code Changed
222. else if(opc==11){ Formatted: English (United States)
223. printf("fcba73\n");
224. i245 = strcspn (str210,keys2); Formatted: English (United States)
225. printf ("El primer numero en str2 esta en la posicion
%d.\n",i245+1);
226.
227. auxsld=vrpeticion();
228. }
229. else if(opc==12){
230. pFile = fopen ("libro_quimica","r");
231. if (pFile == NULL)
232. printf ("Error al abrir el archivo libro_quimica.txt:
%s\n",strerror(errno));
233.
234. auxsld=vrpeticion();
235. }
236. else if(opc==13){
237. printf("Introduce la frase: ");
238. while(getchar()!='\n');
239. gets(szInput);
240. printf("La oraci�n ingresada tiene %u caracteres de
largo.\n",(unsigned)strlen(szInput));
241.
242. auxsld=vrpeticion();
243. }
244. else if(opc==14){
245.
246. strcpy (str134,"hola planeta");
247. strcpy (str234,"mundo tierra");
248. strncat (str134, str234, 6);
249. printf("hola planeta\n mundo tierra\n");
250. puts (str134);
251. auxsld=vrpeticion();
252. }
253. else if(opc==15){
254.
255. puts ("buscar codigos IR cifrados...");
256. for (n45=0 ; n45<3 ; n45++)
257. if (strncmp (str45[n45],"R2xx",2) == 0) Formatted: English (United States)
258. {
259. printf ("Encontrado %s\n",str45[n45]); Formatted: English (United States)
260. } Field Code Changed
261. auxsld=vrpeticion();
262. } Formatted: English (United States)
263. else if(opc==16){
Formatted: English (United States)
264.
265. /* copy to sized buffer (overflow safe): */ Field Code Changed
266. strncpy ( str214, str114, sizeof(str214) );
Formatted: English (United States)
267.
268. /* partial copy (only 5 chars): */ Formatted: English (United States)
269. strncpy ( str314, str214, 5 );
270. str314[5] = '\0'; /* null character manually added */ Field Code Changed
271. Formatted: English (United States)
272. puts (str114);
273. puts (str214); Formatted: English (United States)
274. puts (str314);
275. auxsld=vrpeticion();
276. }
277. else if(opc==17){
278.
279. printf ("Vocales en '%s': ",str56);
280. pch56 = strpbrk (str56, key56);
281. while (pch56 != NULL)
282. {
283. printf ("%c " , *pch56);
284. pch56 = strpbrk (pch56+1,key56);
285. }
286. printf ("\n");
287. auxsld=vrpeticion();
288. }
289. else if(opc==18){
290. pch78=strrchr(str78,'s');
291. printf("Este es un ejemplo de string\n");
292. printf ("Ultima aparicion de 's' encontrado a los %d \n",pch78-
str78+1);
293.
294. auxsld=vrpeticion();
295. }
296. else if(opc==19){
297.
298. i89 = strspn (strtext,cset89);
299. printf("\n129th\n");
300. printf ("El numero inicial tiene %d digitos.\n",i89);
301. auxsld=vrpeticion();
302. }
303. else if(opc==20){
304.
305. pch00 = strstr (str00,"de Quito");
306. printf("Oracion anterior--> La ESCUELA POLITECNICA NACIONAL
es la mejor de Quito\n");
307. strncpy (pch00,"del Ecuador",11);
308. puts (str00);
309.
310. auxsld=vrpeticion();
311. }
312. else if(opc==21){
313.
314. printf ("Divion en sus partes de la frase \"%s\" en
tokens:\n",str01);
315. pch01 = strtok (str01," ,.-");
316. while (pch01 != NULL)
317. {
318. printf ("%s\n",pch01);
319. pch01 = strtok (NULL, " ,.-");
320. }
321. auxsld=vrpeticion();
322. }
323. else if(opc==22){
324.
325. i011 = strxfrm( s1011, s2011, 4 );
326. printf( "s2=%s\n", s2011 ); Formatted: English (United States)
327. printf( "s1=%s\tlonguitud=%d\n", s1011, i011 );
328. auxsld=vrpeticion(); Formatted: English (United States)
329. } Field Code Changed
330.
331. Formatted: English (United States)
332.
Field Code Changed
333.
334. Formatted: English (United States)
335. else if(opc<1||opc>22){
Formatted: English (United States)
336. system("cls");
337. printf("\nOpcion incorrecta!\n\n");
338. printf("\a");
339. auxsld=1;
340.
341. }
342. }while(auxsld==1);
343. printf("\a");
344. return 0;}
345.

FUNCIONES DE CARÁCTER <ctype.h>


El archivo de cabecera ctype.h define un grupo de funciones /macros de manipulación de
caracteres. Todas las funciones devuelven un resultado de valor verdadero (distinto cero) o falso.
Funciones de comprobación alfabética y de dígitos
isalpha ( c )
Devuelve verdadero (distinto de cero) si c es una letra mayúscula o minúscula. Se devuelve un
valor falso si se pasa un carácter distinto de letra a esta función.
islower ( c )
Devuelve verdadero (distinto de cero) si c es una letra minúscula. Se devuelve un valor falso(falso
(0), si se pasa un carácter distinto de una minúscula.
iIsupper ( c )
Devuelve verdadero (distinto cero) si c es una letra mayúscula, falso con cualquier otro carácter.
Para caracteres numéricos
iIsdigit ( c )
Comprueba si c es un digito de 0 a 9, devolviendo verdadero (distinto de cero ) en ese caso, y
falso en caso contrario.
iIsxdigit ( c )
Devuelve verdadero si c es cualquier digito hexadecimal ( 0 a 9. A a F , o bien a a f ) y falso en
cualquier otro caso.
Para numéricos a alfabéticos
iIsalnum ( c )
Devuelve un valor verdadero si c es un digito de 0 a 9 o un carácter alfabético (bien mayúscula o
minúscula )minúscula) y falso en cualquier otro caso.
Funciones de prueba de caracteres especiales
Algunas funciones incorporadas a la biblioteca de funciones comprueban caracteres
especialescaracteres especiales, principalmente a efectos de legibilidad.
Estas funciones son las siguientes:
iIscntrl ( c )
Devuelve verdadero si c es un carácter de control (códigos ASCII 0 a 31 )31) y falso en caso
contrario.
iIsgraph ( c )
Devuelve verdadero si c es un carácter imprimible (no de control) excepto espacio; en caso
contrario, se devuelve falso.
iIsprint ( c )
Devuelve verdadero si c es un carácter imprimible (código ASCII 32 a 127 ) incluyendo un espacio;
en caso contrario, se devuelve falso.
iIspunct ( c )
Devuelve verdadero si c es cualquier carácter de puntuación (un carácter imprimible distinto de
espacio, letra o digito); falso, en caso contrario.
iIsspace ( c )
Devuelve verdadero si c es carácter un espacio, nueva línea (\n), retorno de carro (\r), tabulación
( \t ) o tabulación vertical (\v).
Funciones de conversión de caracteres
tTolower ( c )
Convierte el carácter c a minúscula, si ya no lo es.
tToupper ( c )
Convierte el carácter c a mayúscula, si ya no lo es.
NOTA: Antes de copiar el código para llevarlo al compilador se debe sombrear y quitar el
enumerado (Esto evitara que se copie el código con la enumeración).

1. //funciones de caracteres ctype.h


2. #include<stdio.h>
3. #include<ctype.h>//libreria a utilizar
4. #include<stdlib.h>
5. /**/
6.
7. int vrpeticion(void){
8. int auxsld;
9. do{
10.
11. printf("\n1.Repetir programa");
12. printf("\n2.Salir del programa\n");
13. scanf("%d",&auxsld);
14. if(auxsld!=1&&auxsld!=2){
15. printf("\nOpcion incorrecta!");
16. printf("\a");
17. system("cls");
18. } Formatted: English (United States)
19. }while(auxsld!=1&&auxsld!=2);
20. system("cls");// system("clear"); linux - Field Code Changed
- system("cls"); windows Formatted: English (United States)
21. return auxsld;
Formatted: English (United States)
22. }
23. int main(void){
24. int opc,auxsld,operadorsalida;
25. char c;
26. system("color F0");
27. do{
28. printf("\t\t\t\t\t\t<ctype.h>\n"); Formatted: English (United States)
29.
30. printf("--COMPROBACION ALFABETICA Y DE DIGITOS--\n"); Formatted: English (United States)
31. printf("\t\t\t1.Funcion isalpha(c)\n"); Formatted: English (United States)
32. printf("\t\t\t2.Funcion islower(c)\n");
33. printf("\t\t\t3.Funcion isupper(c)\n"); Field Code Changed
34. printf("\t\t\t4.Funcion isdigit(c)\n");
Formatted: English (United States)
35. printf("\t\t\t5.Funcion isxdigit(c)\n");
36. printf("\t\t\t6.Funcion isalnum(c)\n"); Field Code Changed
37.
Formatted: English (United States)
38. printf("--PRUEBA DE CARACTERES ESPECIALES--\n");
39. Formatted: English (United States)
40. printf("\t\t\t7.Funcion iscntrl(c)\n");
41. printf("\t\t\t8.Funcion isgraph(c)\n"); Field Code Changed
42. printf("\t\t\t9.Funcion isprint(c)\n"); Formatted: English (United States)
43. printf("\t\t\t10.Funcion ispunct(c)\n");
44. printf("\t\t\t11.Funcion isspace(c)\n"); Formatted: English (United States)
45. printf("--CONVERSION DE CARACTERES--\n"); Formatted: English (United States)
46. printf("\t\t\t12.Funcion tolower(c)\n");
47. printf("\t\t\t13.Funcion toupper(c)\n\n"); Field Code Changed
48. Formatted: English (United States)
49. printf("ELIJA UNA OPCION: ");
50. scanf("%d",&opc); Formatted: English (United States)
51. if(opc==1){ Formatted: English (United States)
52. printf("\n Cual es su primer caracter inicial?:
"); Field Code Changed
53. scanf("%c",&c); Formatted: English (United States)
54. while(!isalpha(c)){// solo letras mayusculas y minusculas
55. Formatted: English (United States)
56. printf("\n Caracter no alfabetico");
Field Code Changed
57. printf("\n Cual es su siguiente inicial?: ");
58. scanf("%c",&c); Formatted: English (United States)
59. while(getchar()!='\n');
Formatted: English (United States)
60. }
61. Field Code Changed
62. printf("\n � Terminado !");
Formatted: English (United States)
63. auxsld=vrpeticion();
64. } Formatted: English (United States)
65. else if(opc==2){
Field Code Changed
66. printf("\nIngrese una letra minuscula si no es
minuscula se presentara en pantalla 0: "); Formatted: English (United States)
67. while(getchar()!='\n');
Formatted: English (United States)
68. scanf("%c",&c);
69. if(!islower(c)){// Lectura de solo letras minusculas Field Code Changed
70. printf("\n 0 ");
71. } Formatted: English (United States)
72. else{ Formatted: English (United States)
73. printf("\nCorrecto es una letra minuscula");
74. } Field Code Changed
75. auxsld=vrpeticion(); Formatted: English (United States)
76. }
77. else if(opc==3){ Formatted: English (United States)
78. printf("Ingrese una letra MAYUSCULA si no es
mayuscula se presenta en pantalla el valor 0: ");
79. while(getchar()!='\n');
80. scanf("%c",&c);
81. if(!isupper(c)){//lectura de letras solo MAYUSCULAS
82. printf("\n 0 ");
83. }
84. else{
85. printf("\nCorrecto es una letra MAYUSCULA");
86. }
87. auxsld=vrpeticion();
88. }
89. else if(opc==4){
90. printf("\n Ingrese un digito del 0-9 si no
corresponde se presentara en pantalla en valor 0: ");
91. while(getchar()!='\n');
92. scanf("%c",&c); // Formatted: Italian (Italy)
http://www.cplusplus.com/reference/cctype/isdigit/
93. if(!isdigit(c)){//lectura de los primeros digitos Field Code Changed
94. printf("\n 0 "); Formatted: Italian (Italy)
95.
96. } Formatted: Italian (Italy)
97. else{
98. printf("\nCorrecto es un dijito ");
99. }
100. auxsld=vrpeticion();
101. }
102. else if(opc==5){
103. printf("\n Ingrese un digito
hexadecimal \n ( 1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) si no corresponde se
presentara en pantalla en valor 0: ");
104.
105. while(getchar()!='\n');
106. scanf("%c",&c);
107. if(!isxdigit(c)){//lectura de los primeros digitos
108. printf("\n 0 ");
109.
110. }
111. else{
112. printf("\nCorrecto es un digito hexadecimal");
113. }
114. auxsld=vrpeticion();
115. }
116. else if(opc==6){
117. printf("\n Ingrese un digito o un caracter
alfabetico si no corresponde se presentara en pantalla en valor 0: ");
118.
119. while(getchar()!='\n');
120. scanf("%c",&c);
121. if(!isalnum(c)){//lectura de los primeros digitos
122. printf("\n 0 ");
123.
124.
125. }
126. else{
127. if(isdigit(c)){
128. printf("\nCorrecto es un
dijito");
129. }
130. else if(isalpha(c)){
131. printf("\nCorrecto
es un caracter alfabetico");
132. }
133. }
134.
135. auxsld=vrpeticion();
136. }
137. else if(opc==7){
138. printf("\n Ingrese un caracter de control(ASCII 0-
31) si no corresponde se presentara en pantalla en valor 0: ");
139.
140. while(getchar()!='\n');
141. scanf("%c",&c);
142. if(!iscntrl(c)){//lectura de los primeros digitos
143. printf("\n 0 ");
144.
145. }
146. else{
147. printf("\nCorrecto es un caracter de control");
148. }
149. auxsld=vrpeticion();
150. }
151. else if(opc==8){
152. printf("\n Ingrese un caracter imprimible si no
corresponde se presentara en pantalla en valor 0: ");
153.
154. while(getchar()!='\n');
155. scanf("%c",&c);
156. if(!isgraph(c)){//lectura de los primeros digitos
157. printf("\n 0 ");
158.
159. }
160. else{
161. printf("\nCorrecto es un caracter Imprimible");
162. }
163. auxsld=vrpeticion();
164. }
165. else if(opc==9){
166. printf("\n Ingrese un caracter imprimible ASCII 32-127 si
no corresponde se presentara en pantalla en valor 0: ");
167.
168. while(getchar()!='\n');
169. scanf("%c",&c);
170. if(!isprint(c)){//lectura de los primeros digitos
171. printf("\n 0 ");
172.
173. }
174. else{
175. printf("\nCorrecto es un caracter Imprimible ASCII
32-127");
176. }
177. auxsld=vrpeticion();
178. }
179. else if(opc==10){
180. printf("\n Ingrese un caracter de puntuacion
imprimible si no corresponde se presentara en pantalla en valor 0: ");
181.
182. while(getchar()!='\n');
183. scanf("%c",&c);
184. if(!ispunct(c)){//lectura de los primeros digitos
185. printf("\n 0 ");
186.
187. }
188. else{
189. printf("\nCorrecto es un caracter de puntuacion");
190. }
191. auxsld=vrpeticion();
192. }
193. else if(opc==11){
194. printf("\n Ingrese un
caracter||espacio||\\n||\\r||\\t||\\v si no corresponde se presentara en
pantalla en valor 0: ");
195.
196. while(getchar()!='\n');
197. scanf("%c",&c);
198. if(!isspace(c)){//lectura de los primeros digitos
199. printf("\n 0 ");
200.
201. }
202. else{
203. printf("\nCorrecto es un
caracter||espacio||\\n||\\r||\\t||\\v ");
204. }
205. auxsld=vrpeticion();
206. }
207. else if(opc==12){
208. printf("\nIngrese unA letra MAYUSCULA para
convertir a minuscula: ");
209. while(getchar()!='\n');
210. scanf("%c",&c);
211. printf("La letra es %c\n",tolower(c));
212. auxsld=vrpeticion();
213. }
214. else if(opc==13){
215. printf("\nIngrese unA letra minuscula para
convertir a MAYUSCULA: ");
216. while(getchar()!='\n');
217. scanf("%c",&c);
218. printf("La letra es %c\n",toupper(c));
219. auxsld=vrpeticion();
220. }
221.
222. else if(opc<1||opc>13){
223. system("cls");
224. printf("\nOpcion incorrecta!\n\n");
225. printf("\a");
226. auxsld=1;
227.
228. }
229. }while(auxsld==1);
230. printf("\a");
231.
232. return 0;
233. }
234.

FUNCIONES DE FECHA Y HORA <time.h>


La familia de microprocesadores 80x86 tiene un sistema de reloj que se utiliza principalmente
para controlar el microprocesador, pero se utiliza también para calcular la fecha y la hora.
La fecha se guarda de acuerdo con el calendario gregoriano.
Funciones de manipulación del tiempo
clock Programa de Reloj.
difftime Diferencia de retorno entre dos veces.
mktime Convierta la estructura tm en time_t.
time Obtener la hora actual.
Funciones de conversión
asctime Convierta la estructura tm a cadena.
ctime Convierta el valor de time_t en cadena.
gmtime Convierta time_t en tm como hora UTC.
localtime Convierta time_t a tm como hora local.
strftime Formato de tiempo como cadena.
NOTA: Antes de copiar el código para llevarlo al compilador se debe sombrear y quitar el
enumerado (Esto evitara que se copie el código con la enumeración).

1. //funciones de tiempo time.h


2. #include<stdio.h>
3. #include<time.h>//libreria a utilizar
4. #include<stdlib.h>
5. #include <math.h>
6. #define MST (-7)
7. #define UTC (0)
8. #define CCT (+8)
9. /**/
10. int frequency_of_primes (int n) {
11. int i,j;
12. int freq=n-1;
13. for (i=2; i<=n; ++i) for (j=sqrt(i);j>1;--j) if (i%j==0) {-- Formatted: English (United States)
freq; break;}
14. return freq; Field Code Changed
15. } Formatted: English (United States)
16.
17. int vrpeticion(void){ Formatted: English (United States)
18. int auxsld;
19. do{
20.
21. printf("\n1.Repetir programa");
22. printf("\n2.Salir del programa\n");
23. scanf("%d",&auxsld);
24. if(auxsld!=1&&auxsld!=2){
25. printf("\nOpcion incorrecta!");
26. printf("\a");
27. system("cls");
28. }
29. }while(auxsld!=1&&auxsld!=2);
30. system("cls");// system("clear"); linux - Formatted: English (United States)
- system("cls"); windows
31. return auxsld; Formatted: English (United States)
32. } Field Code Changed
33.
34. int main(void){ Formatted: English (United States)
35. int opc,auxsld,operadorsalida;
36. time_t rawtime;//
37. struct tm * timeinfo;//
38. clock_t t;
39. int f;
40. time_t now;
41. struct tm newyear;
42. double seconds;
43. struct tm * ptm; Formatted: English (United States)
44. int year, month ,day;
Field Code Changed
45. const char * weekday[] = { "Domingo", "Lunes",
46. "Martes", "Miercoles", Formatted: English (United States)
47. "Jueves", "Viernes", "Sabado"};
Formatted: English (United States)
48. char buffer [80];
49. time_t timer; Field Code Changed
50. struct tm y2k = {0};
Formatted: English (United States)
51.
52. Formatted: English (United States)
53. system("color F0");
54. do{ Field Code Changed
55. printf("\t\t\t\t\t\t<time.h>\n"); Formatted: English (United States)
56.
57. printf("--FUNCIONES DE FECHA Y HORA--\n"); Formatted: English (United States)
58. printf("\t\t\t1.Funcion asctime\n"); Formatted: English (United States)
59. printf("\t\t\t2.Funcion clock\n");
60. printf("\t\t\t3.Funcion ctime\n"); Formatted: English (United States)
61. printf("\t\t\t4.Funcion difftime\n"); Field Code Changed
62. printf("\t\t\t5.Funcion gmtime\n");
63. printf("\t\t\t6.Funcion localtime\n"); Field Code Changed
64. printf("\t\t\t7.Funcion mktime\n"); Formatted: English (United States)
65. printf("\t\t\t8.Funcion strftime\n");
66. printf("\t\t\t9.Funcion time\n"); Formatted: English (United States)
67.
Field Code Changed
68. printf("ELIJA UNA OPCION: ");
69. scanf("%d",&opc); Formatted: English (United States)
70. if(opc==1){
Formatted: English (United States)
71. time ( &rawtime );
72. timeinfo = localtime ( &rawtime ); Formatted: English (United States)
73. printf ( "La fecha y hora actual es: %s", asctime (timeinfo) );
Field Code Changed
74. auxsld=vrpeticion();
75. } Formatted: English (United States)
76. else if(opc==2){
77. t = clock(); Formatted: English (United States)
78. printf ("Calculando...\n"); Field Code Changed
79. printf ("Por favor espere...\n");
80. f = frequency_of_primes (999999); Formatted: English (United States)
81. printf ("La cantidad de numeros primos inferiores a 100,000 es: Formatted: English (United States)
%d\n",f);
82. t = clock() - t; Formatted: English (United States)
83. printf ("Me llevo %d clics (%f Formatted: English (United States)
segundos).\n",t,((float)t)/CLOCKS_PER_SEC);
Field Code Changed
84. auxsld=vrpeticion();
85. }
86. else if(opc==3){
Formatted: English (United States)
87. time (&rawtime);
88. printf ("La hora actual local es: %s", ctime (&rawtime)); Formatted: English (United States)
89. auxsld=vrpeticion();
90. } Field Code Changed
91. else if(opc==4){ Formatted: English (United States)
92. time(&now); /* get current time; same as: now =
time(NULL) */ Field Code Changed
93. Formatted: English (United States)
94. newyear = *localtime(&now);
95. Formatted: English (United States)
96. newyear.tm_hour = 0; newyear.tm_min = 0; newyear.tm_sec = 0; Field Code Changed
97. newyear.tm_mon = 0; newyear.tm_mday = 1;
98. Formatted: English (United States)
99. seconds = difftime(now,mktime(&newyear)); Formatted: English (United States)
100.
101. printf ("%.f segundos desde a@o nuevo en la zona horaria Field Code Changed
actual.\n", seconds);
Formatted: English (United States)
102. auxsld=vrpeticion();
103. } Formatted: English (United States)
104. else if(opc==5){
Field Code Changed
105. time ( &rawtime );
106. Formatted: English (United States)
107. ptm = gmtime ( &rawtime );
Formatted: English (United States)
108.
109. puts ("Hora actual en todo el mundo:"); Field Code Changed
110. printf ("Phoenix, AZ (U.S.) : %2d:%02d\n", (ptm-
>tm_hour+MST)%24, ptm->tm_min); Formatted: English (United States)
111. printf ("Reykjavik (ISLANDIA) : %2d:%02d\n", (ptm- Formatted: English (United States)
>tm_hour+UTC)%24, ptm->tm_min);
112. printf ("Pekin (China) : %2d:%02d\n", (ptm- Formatted: English (United States)
>tm_hour+CCT)%24, ptm->tm_min); Field Code Changed
113. auxsld=vrpeticion();
114. } Formatted: English (United States)
115. else if(opc==6){ Formatted: English (United States)
116. time (&rawtime);
117. timeinfo = localtime (&rawtime); Field Code Changed
118. printf ("La hora y fecha local actual: Formatted: English (United States)
%s", asctime(timeinfo));
119. auxsld=vrpeticion(); Formatted: English (United States)
120. }
Field Code Changed
121. else if(opc==7){
122. /* prompt user for date */ Formatted: English (United States)
123. printf ("Ingrese el a%co:
Formatted: English (United States)
",164); fflush(stdout); scanf ("%d",&year);
124. printf ("Ingrese el mes: Formatted: English (United States)
"); fflush(stdout); scanf ("%d",&month);
Formatted: English (United States)
125. printf ("Ingrese el dia:
"); fflush(stdout); scanf ("%d",&day); Formatted: English (United States)
126.
127. /* get current timeinfo and modify it to the user's Field Code Changed
choice */ Field Code Changed
128. time ( &rawtime );
129. timeinfo = localtime ( &rawtime ); Formatted: English (United States)
130. timeinfo->tm_year = year - 1900; Formatted: English (United States)
131. timeinfo->tm_mon = month - 1;
132. timeinfo->tm_mday = day; Field Code Changed
133. Formatted: English (United States)
134. /* call mktime: timeinfo->tm_wday will be set */
Formatted: English (United States)
135. mktime ( timeinfo );
136.
137. printf ("Este dia es un %s.\n", weekday[timeinfo->tm_wday]);
138.
139. auxsld=vrpeticion();
140. }
141. else if(opc==8){
142. time (&rawtime);
143. timeinfo = localtime (&rawtime);
144.
145. strftime (buffer,80,"Ahora son las %I:%M
%p.",timeinfo);
146. puts (buffer);
147. auxsld=vrpeticion();
148. }
149. else if(opc==9){
150. y2k.tm_hour = 0; y2k.tm_min = 0; y2k.tm_s
ec = 0;
151. y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1;
152.
153. time(&timer); /* get current time; same as: timer Formatted: English (United States)
= time(NULL) */
154. Formatted: English (United States)
155. seconds = difftime(timer,mktime(&y2k)); Field Code Changed
156.
157. printf ("%.f segundos desde el 1 de enero de 2000 Field Code Changed
en la zona horaria actual", seconds);
Formatted: English (United States)
158. auxsld=vrpeticion();
159. } Formatted: English (United States)
160.
Formatted: English (United States)
161. else if(opc<1||opc>17){
162. system("cls"); Formatted: English (United States)
163. printf("\nOpcion incorrecta!\n\n");
164. printf("\a"); Field Code Changed
165. auxsld=1;
166.
167. }
168. }while(auxsld==1);
169. printf("\a");
170.
171. return 0;
172. }

Conclusiones
Las librerías mencionadas nos facilitan la escritura de código.
Las funciones de cada librería son específicas y tienen restricciones para ciertos casos.
Las funciones pueden recibir varios o solo un argumento a la vez.
Bibliografía
Luis Joyanes Aguilar, Programación C ,2018/02/12, Paginas 234-242.
Cplusplus,2000-2017, 2018/02/12, http://www.cplusplus.com/reference/cstring/

S-ar putea să vă placă și