Advertisement
ViniciusArruda

Generate output grid.

Dec 18th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. /*
  2.  * Made by: Vinicius Arruda
  3.  * E-mail: vinicius_farruda@hotmail.com
  4.  * Blog: csvacation.wordpress.com
  5.  */
  6.  
  7. #include<stdio.h>
  8. #include<stdlib.h>
  9.  
  10. int main(int argc, char **argv)
  11. {
  12.     int i, j, tam;              
  13.     FILE *arquivo;
  14.    
  15.     if(argc < 3)
  16.     {
  17.         printf("Usage: ./%s OutputFileName.txt GridDimension\n", argv[0]);
  18.         return(1);
  19.     }
  20.  
  21.  
  22.     if( (arquivo = fopen(argv[1], "w") ) == NULL)
  23.     {
  24.         printf("Erro ao abrir o arquivo !\n");
  25.         return(1);
  26.     }  
  27.            
  28.     tam = atoi(argv[2]);
  29.  
  30.    
  31.    
  32.     for(i=0; i<tam; i++)
  33.     {
  34.         for(j=0; j<tam; j++)
  35.             putc('-',arquivo);
  36.     putc('\n',arquivo);
  37.     }
  38.            
  39.            
  40.     fclose(arquivo);
  41.  
  42.     return(0);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement