×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

obtaining data from string.

obtaining data from string.

obtaining data from string.

(OP)
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.

RE: obtaining data from string.

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

RE: obtaining data from string.

Try the ANSI strtok function defined in <string.h> which is used to extract fields separated by a token (colon in your case).

TiL

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources