ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo042.c File Reference
#include <stdio.h>
#include <string.h>
Include dependency graph for Ejemplo042.c:

Go to the source code of this file.

Macros

#define N   50

Functions

int main (int argc, char *argv[])

Macro Definition Documentation

◆ N

#define N   50

Definition at line 4 of file Ejemplo042.c.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 6 of file Ejemplo042.c.

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