Hello, i am new in c programming it is just the second month i i deal with. I am really confusing about what i have to do with this exercise pls don't lough on me I hope for some help. That's what i have to do..

I have to modify an .ini file.
The user should enter a name which must be name1 or name2 else he get an error.
The user should enter the value of the name
the format is name1(or 2)=value
If the user use -D the input gets delete from ini
if the user dont enter both name and value gets an error
if the arguements allready exist replace them, if not add them
close file.


Thats what i have tried i have stuck soz again for this bad programme as i said its my second month

#include <iostream> 
#include <conio.h>
#include <stdio.h>
#include <string.h>

int delete= 0;


char parname[20];
char valname[20];
FILE *fdin;
char file[300];
char infile[60];


void main(int argc, char* argv[])
{if (argc!=3)
return;
strcpy(parname,argv[1]);
printf("Enter Parameter Name= %s \n",parname);
printf("Enter the value= %s \n",valname);
if ((fdin=fopen(infile,"r"))==NULL)
{ printf ("Open Error");
return;
}
for (n=0 ; fgets(file,sizeof(file),fdin); ++n)

for (i=2;i<argc;++i)
{ if(strcmp(argv[i],"-D")==0)
delete=-1;

Like we said in your other post, you need to decide if you want to write a C program or a C++ program.

#include <iostream>     // C++
#include <conio.h>      // non-standard- don't use
#include <stdio.h>      // C
#include <string.h>     // C

int delete= 0;


char parname[20];
char valname[20];
FILE *fdin;             // C
char file[300];
char infile[60];


void main(int argc, char* argv[])  // neither -- main is an INT
{if (argc!=3)
return;
strcpy(parname,argv[1]);                         // C
printf("Enter Parameter Name= %s \n",parname);   // C
printf("Enter the value= %s \n",valname);        // C
if ((fdin=fopen(infile,"r"))==NULL)              // C
{ printf ("Open Error");                         // C
return;
}
for (n=0 ; fgets(file,sizeof(file),fdin); ++n)   // C

for (i=2;i<argc;++i)
{ if(strcmp(argv[i],"-D")==0)                    // C
delete=-1;

You've only got one statement (unused) that is C++. Try rewriting it using C++ commands ( cout , string s, etc) and we can help you much better. Or use C and continue with your other thread.

Also, please format your code so everyone -- including you -- can follow it as it gets bigger.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.