Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** @mainpage Hola
- *
- * Este programa saluda educadamente al usuario
- *
- * @section intro_sec Introducción
- *
- * Bla, bla, bla
- *
- * @section uso_sec Modo de uso
- * Para ejecutar el programa
- *
- * @c $./hola
- *
- * etc...
- * @author Pedro Trabajo Cumplido
- * @author Tomas Olo Dejas
- * @author Dolores Fuertes de Barriga
- * @date 2013-02-06
- * @version 1.0
- */
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "frases.h"
- #define TAM 255
- /* egetline: lee un linea y devuelve la longitud,
- o -1 si ha llegado al final de fichero. Termina el programa si hay error. */
- static int egetline(char s[], int lim);
- /**
- * @file main.c
- * Programa principal de saludo
- *
- * Bla, bla, bla
- *
- * @author Pedro Trabajo Cumplido
- */
- int main()
- {
- char nombre[TAM+1];
- char * str;
- egetline(nombre, TAM+1);
- str = saludo(nombre);
- printf("%s\n", str);
- free(str);
- printf("%s\n", despedida());
- return EXIT_SUCCESS;
- }
- static int egetline(char str[], int lim)
- {
- int len;
- if (fgets(str, lim, stdin) == NULL) {
- if (ferror(stdin)) {
- perror("egetline");
- exit(EXIT_FAILURE);
- } else {
- return -1; /* hemos llegado al final del fichero */
- }
- }
- len = strlen(str);
- if (str[len-1] == '\n') {
- str[len-1] = '\0' ; /* elimina el salto de linea */
- len--;
- }
- return len;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement