Code working AIX 5.2 and not in Solaris 5.9


 
Thread Tools Search this Thread
Top Forums Programming Code working AIX 5.2 and not in Solaris 5.9
# 1  
Old 08-09-2006
Network Code working AIX 5.2 and not in Solaris 5.9

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
# 2  
Old 08-09-2006
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, ",");
}
}

you had made use of strcmp - to compare two strings ( here a string and a char array )
but the char array is not terminated,
hold a value and termination value.
# 3  
Old 08-09-2006
Thanks buddy
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

AIX 4.3 - Need help - Printers not working

I am running an old IBM P-Series server running AIX 4.3 (I know a dinosaur). The OS has not been updated. We had a hard drive failure last weekend, and I was able to get most of the system back up, however, I have 3 line printers and 3 label printers that I can not get working. I have tried... (2 Replies)
Discussion started by: Patrick.Crocker
2 Replies

2. Shell Programming and Scripting

Find command not working on AIX

Hello, I am running find command in an AIX Server to find last 7 days modified directories/files. >cd /usr/openv/netbackup/db/class >ls -l total 0 drwxr-xr-x 3 root system 256 May 28 2014 Catalog-Backup drwxr-xr-x 3 root system 256 Sep 18 2012 ... (4 Replies)
Discussion started by: rahul2662
4 Replies

3. AIX

rssh not working in AIX 6.1

edit by bakunin: double post SNIPped. Hi, I have a similar problem with my AIX 6.1. In AIX 5.3, I have successfully implemented rssh for the caging of my SFTP users. Since we just upgraded to AIX 6.1 TL6 SP7, the rssh does not work. The SFTP works when the user's shell is set to ksh, but... (1 Reply)
Discussion started by: eddie.lee
1 Replies

4. Shell Programming and Scripting

Sed script not working properly on Solaris (works fine on AIX)?

Hi, I have a problem with a SED script that works fine on AIX but does not work properly on a Solaris system. The ksh script executes the SED and puts the output in HTML in tables. But the layout of the output in HTML is not shown correctly(no tables, no color). Can anyone tell if there is... (7 Replies)
Discussion started by: Faith111
7 Replies

5. Shell Programming and Scripting

Script working in AIX, but giving error in SOLARIS

Hi, My script is working fine in AIX but throwing an error in SOLARIS system. Here is the error message that I am getting when calculating the elapsed time: /home/x772525/FindETA.sh: start_mins = *60 + : syntax error . ((start_mins = $(expr substr "$j" 1 2)*60 + $(expr substr "$j" 4... (6 Replies)
Discussion started by: ajayakunuri
6 Replies

6. Solaris

Executable compiled on solaris 10 not working on solaris 9

Hi I compiled an executable on Solaris 10 which creates semaphore ( semget) but it didn't work on solaris 9 , while it is executing sucessfully on solaris 10. It is throwing the system error that Invalid arguments ( system error 22) on solaris 9. the ldd for the executable on two servers is as... (4 Replies)
Discussion started by: ash_bit2k2
4 Replies

7. UNIX for Advanced & Expert Users

rm -rf not working on AIX 6.1

Hi Guys, I have never seen this happen before, but created a directory as a user when installing some software, software install fails so I try and remove the directory as root and get an error. There is no processes using the folder see output: ls -l total 446336 -rwxr----- 1 u0008862... (2 Replies)
Discussion started by: chris5126
2 Replies

8. AIX

suid not working on AIX ?

Hello, I'm running AIX 6.1 box. I tried to use suid on binary file but it doesn't work. (I set suid on /usr/bin/sleep and tried to run it as user1(sleep owner is bin) - and program still runs as user1. It shoud run as bin isn't it ? - This test run as expected on Linux box) Filesystem is... (3 Replies)
Discussion started by: vilius
3 Replies

9. Shell Programming and Scripting

*/5 not working in AIX

Hi Guys, I tried to schedule a script for every 5 mins. i tried */5 but it is not working. Is writing every 5 mins is the only way to do it? like below 05,10,15,20,25,30,35,40,45,50,55 05-08 Thanks And Regards, Magesh (11 Replies)
Discussion started by: mac4rfree
11 Replies

10. AIX

^P Not working on AIX.

I'm working on an AIX box, and I generall prefer emacs command line editing in ksh. Most control-commands are working, except not control-P (Recall previous command). ksh set - o emacs ^p Does not result in the expected outcome. does anyone know why this might be? (0 Replies)
Discussion started by: akbar
0 Replies
Login or Register to Ask a Question

Featured Tech Videos