Eric Sosman
5/14/2011 2:19:00 PM
On 5/14/2011 9:02 AM, janus wrote:
> Thanks you all.
>
> However, I have additional question ..
>
> Is this acceptable?
> char string[] = "Simulated Annealing = 857747716";
> char astring[] = "Karmarkar 625874153";
>
> char * value = strchr(astring ,'=');
> char * avalue;
>
> if(value != NULL){
Since `value' will be NULL, this part is not executed.
> *(value ++) = 0;
> printf("%s=====%s\n", value, string);
> }
> else if((value == NULL)&& (avalue = strchr(astring, ''))){
This is a syntax error. You probably meant ' ', not ''. (Also,
since "value != NULL" has already been found false, "value == NULL"
is sure to be true. There's no actual harm in making a test that
can only turn out one way, but it's silly.)
> *(avalue ++) = 0;
> printf("%s====%s\n", avalue, astring);
With the correction, this should print " 625874153====Karmarkar".
> }
>
> Is the above correct?
Impossible to say, since you haven't told us what you want
the code to do!
--
Eric Sosman
esosman@ieee-dot-org.invalid