Advertisement
phayauam

Ejemplo documentación main.c

Feb 6th, 2013
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.48 KB | None | 0 0
  1. /** @mainpage Hola
  2.  *
  3.  * Este programa saluda educadamente al usuario
  4.  *
  5.  * @section intro_sec Introducción
  6.  *
  7.  * Bla, bla, bla
  8.  *
  9.  * @section uso_sec Modo de uso
  10.  * Para ejecutar el programa
  11.  *
  12.  * @c $./hola  
  13.  *
  14.  * etc...
  15.  * @author Pedro Trabajo Cumplido
  16.  * @author Tomas Olo Dejas
  17.  * @author Dolores Fuertes de Barriga
  18.  * @date 2013-02-06
  19.  * @version 1.0
  20.  */
  21.  
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <stdlib.h>
  25. #include "frases.h"
  26.  
  27. #define TAM 255
  28.  
  29. /* egetline: lee un linea y devuelve la longitud,
  30.    o -1 si ha llegado al final de fichero. Termina el programa si hay error. */
  31. static int egetline(char s[], int lim);
  32.  
  33. /**
  34.  * @file main.c
  35.  * Programa principal de saludo
  36.  *
  37.  * Bla, bla, bla
  38.  *
  39.  * @author Pedro Trabajo Cumplido
  40.  */
  41. int main()
  42. {
  43.     char nombre[TAM+1];
  44.     char * str;
  45.            
  46.     egetline(nombre, TAM+1);
  47.        
  48.     str = saludo(nombre);
  49.     printf("%s\n", str);
  50.     free(str);
  51.  
  52.     printf("%s\n", despedida());
  53.    
  54.     return EXIT_SUCCESS;
  55. }
  56.  
  57. static int egetline(char str[], int lim)
  58. {
  59.     int len;
  60.  
  61.     if (fgets(str, lim, stdin) == NULL) {
  62.         if (ferror(stdin)) {
  63.             perror("egetline");
  64.             exit(EXIT_FAILURE);
  65.         } else {
  66.             return -1;  /* hemos llegado al final del fichero */
  67.         }
  68.     }    
  69.    
  70.     len = strlen(str);
  71.     if (str[len-1] == '\n') {
  72.         str[len-1] = '\0' ; /* elimina el salto de linea */
  73.         len--;
  74.     }
  75.     return len;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement