Stu wrote:
Can somebody give me a scanf statment that will parse out the value
between the pipe signs but not including the the pipe signs.
@xxx:|this value|
Thanks to all that answer this post.
Why scanf?
Just read the line in a buffer, then:
char *start = strchr(line,'|'); // find the first |
char *end = strrchr(line,'|'); // find the last |
if (start)
start++; // start points to the start of the data
else {
// treat error
}
if (end) {
// Zero terminate the data
*end = 0;
}
else {
// reat error
}
strcpy(destination_buffer,start);
This will parse
@xxx;| this value with embedded | signs that are ignored|
correctly, unlike scanf. Besides the code is much simpler.
Scanf is kind of too fragile to be used in serious contexts.
(My personal opinion)
jacob