strchr will return the position of the first '=' in the string without having to modify the string itself.
It will return the "=ny" part, so incrementing it one from there will make it return the "ny" part. This assumes that the string includes '=' in it, if it doesn't it will break. But that's taken care of by prefix.
strchr will return the position of the first '=' in the string without having to modify the string itself.
It will return the "=ny" part, so incrementing it one from there will make it return the "ny" part. This assumes that the string includes '=' in it, if it doesn't it will break. But that's taken care of by prefix.
thanks!
but the catch here (which I just realized) is I need to know if they ever pass just "markid=". This means they want to clear the field....
So with the above suggestion, when they passed in "markid=", I would get NULL I assume?
Since the input still includes a '=', strchr would still find one. Moving one beyond that would get you to the NULL terminator, aka you'd have an empty string. You can easily test that by looking for the null terminator:
Since the input still includes '=', strchr would still fine one. Moving one beyond that would get you to the NULL terminator, aka you'd have an empty string. You can easily test that by looking for the null terminator:
Why is line (null) after the first while loop run? (keyword does jump to the next word.)
#include <ftw.h>
#include <stdio.h>
#include <string.h>
char filenames = "";
int list(const char *name, const struct stat *status, int type)
{
if( (type == FTW_F) && strstr(name, ".txt") &&... (3 Replies)
Hi,
I just wrote a program in C to split a comma seperated string in to group of strings using strtok() function. The code is:
int main()
{
char *temp;//not used here but basically we extract one string after another using strtok() and assign to a string pointer defined like this.
... (3 Replies)
can any help me out y dis program is giving me a segmentation fault.....
#include<stdio.h>
#include<string.h>
int main()
{
char *str="Tanvir/home/root/hello";
const char *d ="/";
char *ret;
ret=strtok(str,d);
if(ret==NULL)
printf("NULL NULL");
else
... (3 Replies)