|
thathvamsi wrote: eg., 1, Steve,Dave, 25yrs, California
I want to strip or ignore the comma that is between Steve and Dave and store the data as
1, SteveDave, 25yrs, California
Easy, just read it character by character in a simple for loop, if it's comma, ignore it.
|
|
|
|
|
how to ignore it?
how can i print the data without comma?
|
|
|
|
|
Wait I re-read your question, I misunderstood. I got your question this time.
thathvamsi wrote: eg., 1, Steve,Dave, 25yrs, California
I want to strip or ignore the comma that is between Steve and Dave and store the data as
1, SteveDave, 25yrs, California
You can see if the next character is space, if not, then it's in the datafield.
|
|
|
|
|
I dont understand. sorry.
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
I want to print just Steve, David, Ross by ignoring only that comma that is between 't' and 'e' . i need the other commas to separate the datafields.
how do i do it?
if u can showe some code snippet, thats great.
|
|
|
|
|
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 />
|
|
|
|
|
thanks.
how do i do it if the contents are stored in an array of counted byte strings instead of a file.
eg., row[0]=Steve
row[1] =david
row[3] = ross
|
|
|
|
|
The requirement was to save to a file, not read from it.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hope I understood your question
if you want to delete comma of you can use CString::Find for get commas and then remove their of your string with CString::Delete.
|
|
|
|
|
WhiteSky wrote: Hope I understood your question
I think he is asking how to parse a file that contains comma and want to ignore them when parsing.
|
|
|
|
|
I want it in C programming
|
|
|
|
|
WhiteSky wrote: if you want to delete comma of you can use CString::Find...
This is a C question, not C++/MFC.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thathvamsi wrote:
I want it in C programming
you have to implement logic for same!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
thathvamsi wrote: eg., 1, Steve,Dave, 25yrs, California
If the string to be parsed is "1, Steve,Dave, 25yrs, California", there's no way to reliably differentiate between the various commas. Depending on the placement of a space is unreliable.
Now, if you have control over how the aforementioned string is put together, then a solution is very easy.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I created a edit box and a "apply" button. when i clicked button, I want it can retrieve the value which i typed in the edit box.following is my code, but why it doesnt work?
void CIPConfig::OnBnClickedButton2() // enable
{
UpdateData(FALSE);
int level;
level = atoi(v_level);//v_level is varibale of edit box.
}
|
|
|
|
|
if you want to read of editbox you can use GetWindowText or GetDlgItemInt or GetDlgItemText
|
|
|
|
|
yijia_24 wrote: UpdateData(FALSE);
use
UpdateData( TRUE );
yijia_24 wrote: int level;
level = atoi(v_level);//v_level is varibale of edit box.
u can directly create a int varaiable for the edit control. no need of this..
nave
|
|
|
|
|
yijia_24 wrote: level = atoi(v_level);//v_level is varibale of edit box.
why using atoi function.. you can use DDX_Text directly for integer value
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Thank you very much!
Would you explain to me the difference between UpdateData(FALSE) and UpdateData(TRUE)? I am still very confused about it.
|
|
|
|
|
Thank you very much!
now i need send this data to a socket, do u know how to do it?
Thank you,
yj
|
|
|
|
|
yijia_24 wrote: UpdateData(TRUE)?
when u call the UpdateData(TRUE), the values in the control are set to the value variable created for each control.
When u call the UpdateData(FALSE), the values in the variable is set to the correspoding control.
When u call a UpdateData function, it sets/gets all the value to and from all the controls to the variables. some times u may want to take only the text of one edit control. But in that case also all controls in the dialog are upadated. It slows down the program.
U can use the GetDlgItemText() or SetDlgItemText instead of UpdateData()( I recommend this )
nave
|
|
|
|
|
Thank you very much!
I appreciate you spending time over my questiones.
|
|
|
|
|
yijia_24 wrote: Would you explain to me the difference between UpdateData(FALSE) and UpdateData(TRUE)?
Here is a good article on UpdateData Avoiding UpdateData [^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
yijia_24 wrote: I am still very confused about it.
Which is why you should avoid it. See here for more.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Naveen R wrote: yijia_24 wrote:
UpdateData(FALSE);
use
UpdateData( TRUE );
Another reason why UpdateData() should be avoided.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Not sure where to post this, so I hope the admin will bump it somewhere more appropriate (not /dev/null!)
I am looking at Vista RC1, and am curious about the geomentry shaders in DirectX.
Does anyone know about these?
Is there any/much sample code about?
Thx
Hugh
|
|
|
|