XML : strstr() working on windows but not on AIX, why?

I am writing a test for a software and need it to be rather platform independent.

I have to use strstr() to look for a substring within a string. I have written a program and on windows it works just fine returns what it should and everything is A-OK. But on AIX strstr() fails. It keeps returning null.

What I am doing is opening an XML file and reading it into ONE string : xmlFileString. Now I take some substrings which I know are in the XML file and using strstr I search for them, in AIX it just returns NULL.

Then I thought maybe xmlFileString is not working, but it is working I can print out the entire xml correctly.

      void madeUpFuntionOnlyToExplainTheProblem()  {      const char xmlFileString[6000];      char configFileAddress[1000];      const char temp[1000];        config = fopen(configFileAddress,"r");        while ( fgets ( xmlFileString, 10000, config ) != NULL ) // reads the whole config.xml file into 1 line         {                                     sprintf(temp,"SOMEATTRIBUTEINXML=\"%s\"", someAttributeValueinXML);               s = strstr(xmlFileString, temp);                printf("\nChecking for strstr\n s= %s\n", s);//Here printing the value of s to check what it contains and it is always NULL              printf("%s | ", xmlFileString);//Here printing the entire xmlFileString which turns out to be correct                 if(s!=NULL)               {                   //strstr successfully found something               }               else               {                  //error strstr() did not find anything                 }                }          }    

I don't know much about AIX or linux for that matter. But I am using gxlc compiler and also tried with xlc (don't think it is different then gxlc). Whatever else you want to know please tell me I will try to provide the info.

In case of Linux specific questions if you could tell me the commands to obtain the information you want (like versions and the likes) please tell me.

Thanks in advance for the help.

No comments:

Post a Comment