atoi() not giving correct answer
hii
i m using atoi() to convert char value to int. and then passing that int as a swtich variable. switch goes in a case and exectuing that particualr function but returning 0 value.... for example: i am finding no of process() and system up time(). when switch program goes in system up time it gives right values means correct no of days, hrs , min and sec but when it goes in no of process() it gives 0 answer.... why is it so???? plz help!! Regards! |
Quote:
Andi |
ok here the code
Code:
int snmpget() |
Your question is very confusing. You're talking about atoi() but also about systm_time() working properly and no_of_process() always printing 0.
If atoi() returned the incorrect value (0), you should see 'INCORRECT VALUE' on your screen, so I assume your problem is not with atoi() but with no_of_process(). Correct? PS And you don't call sysinfo() in no_of_process() ! So the sysinfo structure contains random data (possibly zeroes but not guaranteed without seeing the rest of the code) |
yes i knw its very confusing.... actually i didnt understand y this code is doing like this...
i included sysinfo struct in main also. and u know sometimes my program gives correct ans means correct no of process but when i run this code again it gives 0 no of process... i have other paramters also in this program like total and free ram, swaped space, etc.... and same 0 i get even for total ram. and swaped space. sometimes it gives corect ans and sometimes it gives 0.... :-( |
Code:
#include <stdio.h> It runs properly on my system returning a consistent number of processes each time I run it. PS: If all options relate to sysinfo, I would call sysinfo before entering the switch. |
thanx!! :-)
its working fine now!! i exectued my code 3 times and is giving right answer now...!! i wish i dont create prob again... thnx for ur help! Regards! |
Great; was fun for a sunday afternoon ;)
Please mark your thread as solved using the thread tools just above the opening post. One little note: If your original program runs in an endless loop, it will work if you first use option '1' and next option '2'. Option '1' will initialize the sysinfo struct. WimS |
okk!!!
|
All times are GMT -5. The time now is 11:18 PM. |