Hello everyone!!!
Here's the code of my program (not very advanced, I am creating the first menu):
C code
Code:
#include <stdio.h>
#include <stdlib.h>
void file ();
void main ()
{
int iChoix ;
iChoix = 0 ;
printf ( "Welcome to the program GestIp.");
printf ( "\ n \ n This program will allow you to manage your IP address, create a follow-up to all the addresses assigned to a file corresponding to a company. \ n");
printf ( "\ n Please choose the operation you want: \ n \ n");
printf ( "\ t 1 --- Create / open a file \ n");
printf ( "\ t 2 --- Add an IP address \ n");
printf ( "\ t 3 --- Delete an IP address \ n");
printf ( "\ t 4 --- Sort file \ n");
printf ( "\ t 5 --- Saubegarder file \ n");
printf ( "\ t 6 --- Exit Program \ n");
printf ( "\ n Enter the number corresponding to your choice:");
scanf ( "% d", & iChoix);
printf ( "\ n The choice is:% d \ n", iChoix);
switch (iChoix)
{
case 1: system ( "cls");
printf ( "You have chosen to open or create a new file. \ n");
system ( "pause");
file ();
break;
case 2: printf ( "You have chosen to add a new IP address into a file already exists. \ n");
break;
case 3: printf ( "You have chosen to delete an IP address in an already existing file \ n");
break;
case 4: printf ( "You've chosen to sort the file in use. \ n");
break;
case 5: printf ( "You have chosen to save the file in use. \ n");
break ; break;
case 6: printf ( "You have chosen to leave the program. \ n");
break;
default: system ( "cls");
printf ( "ERROR !!!!! The issue is no menu \ n");
system ( "pause");
system ( "cls");
main ();
}
}
void file ()
{
cNomFile char [20];
printf ( "Please enter the file name to create or the name of the file to open:");
sscanf ( "% s", cNomFile);
fopen ( "D: \ \ My Documents \ \ ProgC \ \ ptic \ \ & & cNomFile. txt", "a");
} )
The problem I encounter is the following:
I create a file using the content of "cNomFile" except that I can not make this line of
Code:
fopen ( "D: \ \ My Documents \ \ ProgC \ \ ptic \ \ & & cNomFile. txt", "a");
take into account the content of the variable that is between &. Each time, create the file is the name of the variable directly
Thank you for your help!!
Bookmarks