gives: str=0Code:char str[32]; int x=256; sprintf(str, "%d", x);
is there any way around this?
gives: str=0Code:char str[32]; int x=256; sprintf(str, "%d", x);
is there any way around this?
I can't see anything wrong in the posted code. Can you post a COMPLETE working example of the code (that is, something that can be compiled locally and run on for example my machine). Generally, when this sort of thing happens, the code that has been removed to make the example small is actually part of the problem...
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
sorry, I was using a child process to pass the value of x back into a coordinator process and it seems that exit() can not handle integers above 256..... i think?
I wont need to be handling anything above single digit integers so there are no worries. Solved my own problem, thx MatsCode:pid=fork(); if(pid==-1){ printf("Fork Error\n"); } if(pid==0){ execlp("./worker.o", "./worker.o", x[0], x[1], NULL); } else{ child_pid=wait(&message); if(WIFEXITED(message)){ messageholder=WEXITSTATUS(message); ans[ANSindex]=strdup(itoa(messageholder)); } else printf("Error in subthread\n"); }
Last edited by BMathis; 02-16-2009 at 06:16 PM.