ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo042.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <string.h>
3
4#define N 50
5
6int main(int argc, char *argv[])
7{
8 int i, n;
9 FILE *fp;
10 char filename[N];
11 printf("Ingrese el valor de n: ");
12 scanf("%d", &n);
13 if(argc==2)
14 strcpy(filename, argv[1]);
15 else
16 strcpy(filename, "Prueba.txt");
17 fp = fopen(filename, "wt");
18 if(fp==NULL)
19 return 1;
20 for(i=0; i<n; i++)
21 fprintf(fp, "%d\n", i+1);
22 fclose(fp);
23 return 0;
24}
#define N
int main(void)
Definition Ejemplo_035.c:15