Click here to Skip to main content
15,894,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys,

How can I convert this C++ function into CSharp..? I am just a newbie that want's to learn c# programming..
C++
short MES_EditConfig(char *Detail, char *aParameter)
{
FILE 	*fp;
char 	*fData;
char	fTemp[80];
char 	prjdef[512];
long 	FileSize;

char 	sString[500];
long 	sIndx;
char 	*strCmp;
long 	sCnt;
char 	str_newDetail[50];
int 	len_newDetail;

int 	ErrorFlag=0;

char 	*strA, *strC;

GetProjectDir(prjdef);
sprintf(fTemp  , "%s\\Config.ini", prjdef);

FileSize = GetFileData(fTemp, &fData);
sIndx=0;
sCnt=0;
strCmp = fData;

sprintf(str_newDetail, "%s%s\n", Detail, aParameter);
len_newDetail = strlen(str_newDetail);

while(sCnt<filesize-1)>
{
	while(fData[sCnt]!=10 && sCnt<filesize-1)>
		sCnt++;
	
	CopyString(sString, 0, fData, sIndx, sCnt - sIndx);
	
	if(!strncmp(sString, Detail, strlen(Detail)))
	{
		strA = malloc(sIndx+1);
		strC = malloc(FileSize-sIndx);
			
		CopyString(strA, 0, fData, 0, sIndx);
		CopyString(strC, 0, fData, sCnt+1, -1);
		sprintf(fData, "%s%s%s", strA, str_newDetail, strC);
		
		ErrorFlag=1;
	}
		
	sCnt++;
	sIndx = sCnt;
}

fp = fopen(fTemp, "w");
fputs(fData, fp);
fclose(fp);
return ErrorFlag;
}
Posted
Updated 8-Oct-10 20:45pm
v2

I would suggest you start by learning C# itself. Take a look at .NET Book Zero[^] by Charles Petzold, an excellent way to get started with C#.
 
Share this answer
 
Your function is C, not C++. Anyway, if you want to learn C#, converting C code to C# is hardly the best way to do it. Find some C# book and learn from it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900