![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Solaris 10 Patch Return Code 1; what does it mean | debd | SUN Solaris | 4 | 05-08-2008 07:29 AM |
| Solaris 8 installed but bash is not working | bluridge | SUN Solaris | 2 | 01-24-2008 01:03 PM |
| Solaris 10 - init stops working | GKnight | SUN Solaris | 0 | 05-07-2007 08:04 PM |
| Prtdiag is Not working in Solaris 8 Ver | sure.solaris | SUN Solaris | 7 | 01-26-2007 01:37 PM |
| /usr/bin/cut not working with largefiles on Solaris 10 | wottie | SUN Solaris | 1 | 04-04-2006 02:57 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
When i run the below code in AIX it runs and solaris not ... why ??? #include <stdio.h> #include <string.h> #define MAX 1 int main () { char str[] ="1,2,3,4,5"; char * pch,b[MAX]; int a; printf ("Enter the int to be searched [%s]",str); scanf("%d",&a); sprintf(b,"%d",a); pch = strtok (str,","); while (pch != NULL) { if(!strcmp(pch,b)) /*printf ("%s\n",pch);*/ printf("found"); pch = strtok (NULL, ","); } } Output : Solaris : NIL AIX: found |
| Forum Sponsor | ||
|
|
|
|||
|
right now i dont have access to an IBM node,
and in solaris, herez the code: Code:
#include <stdio.h>
#include <string.h>
#define MAX 1
int main ()
{
char str[] ="1,2,3,4,5";
char * pch,b[MAX + 1];
int a;
printf ("Enter the int to be searched [%s]",str);
scanf("%d",&a);
sprintf(b,"%d",a);
b[MAX]='\0';
pch = strtok (str,",");
while (pch != NULL)
{
if(!strcmp(pch,b))
{
printf("found");
break;
}
pch = strtok (NULL, ",");
}
}
but the char array is not terminated, hold a value and termination value. |