finding character in string C language

Posted by iSight on Stack Overflow See other posts from Stack Overflow or by iSight
Published on 2010-06-03T04:52:34Z Indexed on 2010/06/03 4:54 UTC
Read the original article Hit count: 146

Filed under:

Hi,

I am searching a character at first occurence in string using the following code.

But, it is taking some time when the character is too long or the character that i am

searching is at far extend, which makes delay in other operations. How could i tackle with

this problem. The code is below here.

Note: attrPtr is a char* which holds a reference to a string containing '"' character at

far extend.

int position = 0;

char qolon = '"';//character to search

while (*(attrPtr + position++) != qolon);

char* attrValue = NULL;

attrValue = (char*)malloc(position * sizeof(char));

strncpy(attrValue, attrPtr, position-1);

© Stack Overflow or respective owner

Related posts about c