Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

obtaining data from string.

Status
Not open for further replies.

adrianmah

Computer
Mar 31, 2003
4
0
0
AU
Hi, i am newin this. can you help me on this problem? I am trying to capture a string of data seperated by ":". is this coding correct? else please help.

text of string to capture:
12:Ian Richards:Africa:33 Beach Street:Hervey Bay:4655:(07)4567 8901
34:Yan Li:Secret:13 Mockingbird Lane:Mysteryville:7654:(03)2345 6789

coding:
fscanf(fptr, "%2s %c %[^\:] %c %[^\:]%*[^\:]%*c %c %[^\:] %c %[^\:] %c %[^\n]\n", newPtr->id,o, newPtr->name,o, newPtr->password,o, newPtr->address,o, newPtr->code,o, newPtr->phone);

o is use to capture the ":".
please help.
 
Replies continue below

Recommended for you

If you are doing it using VB.NET, one simple method would be:

Dim linString As String
Dim linVal() As String
linString = 'enter the string you want here...
linVal = linString.Split(":") 'where : = delimiter

linVal will be a string array that you can process further as you see fit
 
Try the ANSI strtok function defined in <string.h> which is used to extract fields separated by a token (colon in your case).

TiL
 
Status
Not open for further replies.
Back
Top