Click here to Skip to main content
15,914,070 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Static Release wrong behavior and Debug fine Pin
Stephen Hewitt3-Oct-06 13:41
Stephen Hewitt3-Oct-06 13:41 
AnswerRe: Static Release wrong behavior and Debug fine Pin
Rudolf Jan3-Oct-06 1:08
Rudolf Jan3-Oct-06 1:08 
Questionstrip characters Pin
thathvamsi2-Oct-06 17:52
thathvamsi2-Oct-06 17:52 
AnswerRe: strip characters Pin
Link20062-Oct-06 18:07
Link20062-Oct-06 18:07 
GeneralRe: strip characters Pin
thathvamsi2-Oct-06 18:20
thathvamsi2-Oct-06 18:20 
GeneralRe: strip characters Pin
Link20062-Oct-06 18:26
Link20062-Oct-06 18:26 
GeneralRe: strip characters Pin
thathvamsi2-Oct-06 18:30
thathvamsi2-Oct-06 18:30 
GeneralRe: strip characters Pin
Link20062-Oct-06 18:56
Link20062-Oct-06 18:56 
thathvamsi wrote:
I have a group of data fields. each data field is separated by comma but the data itself shouldnt have a comma in it. ie., for eg., St,eve, David, Ross


Okay, suppose you have a txt file called data.txt, where the content: St,eve, David

The following code will print Steve David

modify the code a bit yourself to add comma in the end result. Hope that helps.


<br />
#include < stdio.h ><br />
<br />
int main(int argc, char *argv[])<br />
{<br />
        FILE *fp = NULL;<br />
	char buffer[20] = { 0 };<br />
	char ch = 0;<br />
	int i = 0;<br />
<br />
	fp = fopen("data.txt", "r");<br />
	<br />
	for (i = 0; (i < 20) && ((ch = getc(fp)) != EOF) && (ch != '\n'); i++)<br />
	{<br />
		if (ch != ',')<br />
			buffer[i] = (char) ch;<br />
		else<br />
			i--;<br />
	}<br />
<br />
	buffer[i] = '\0';<br />
	printf( "%s\n", buffer);<br />
<br />
	fclose(fp);<br />
<br />
        return 0;<br />
<br />
}<br />

GeneralRe: strip characters Pin
thathvamsi2-Oct-06 20:31
thathvamsi2-Oct-06 20:31 
GeneralRe: strip characters Pin
David Crow3-Oct-06 5:32
David Crow3-Oct-06 5:32 
AnswerRe: strip characters Pin
Hamid_RT2-Oct-06 18:08
Hamid_RT2-Oct-06 18:08 
GeneralRe: strip characters Pin
Link20062-Oct-06 18:20
Link20062-Oct-06 18:20 
GeneralRe: strip characters Pin
thathvamsi2-Oct-06 18:20
thathvamsi2-Oct-06 18:20 
GeneralRe: strip characters Pin
David Crow3-Oct-06 5:33
David Crow3-Oct-06 5:33 
GeneralRe: strip characters Pin
ThatsAlok2-Oct-06 20:19
ThatsAlok2-Oct-06 20:19 
AnswerRe: strip characters Pin
David Crow3-Oct-06 5:38
David Crow3-Oct-06 5:38 
QuestionRead value Pin
yijia_242-Oct-06 17:47
yijia_242-Oct-06 17:47 
AnswerRe: Read value Pin
Hamid_RT2-Oct-06 17:57
Hamid_RT2-Oct-06 17:57 
AnswerRe: Read value Pin
Naveen2-Oct-06 17:57
Naveen2-Oct-06 17:57 
AnswerRe: Read value Pin
ThatsAlok2-Oct-06 19:39
ThatsAlok2-Oct-06 19:39 
QuestionRe: Read value Pin
yijia_242-Oct-06 18:45
yijia_242-Oct-06 18:45 
QuestionRe: Read value Pin
yijia_242-Oct-06 22:16
yijia_242-Oct-06 22:16 
GeneralRe: Read value Pin
Naveen2-Oct-06 18:55
Naveen2-Oct-06 18:55 
GeneralRe: Read value Pin
yijia_242-Oct-06 19:02
yijia_242-Oct-06 19:02 
AnswerRe: Read value Pin
S Douglas3-Oct-06 0:09
professionalS Douglas3-Oct-06 0:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.