1) assigning a normal char array[], to another char *array[i], ( the result suggests so )
thanks in advance
BujarM
1) assigning a normal char array[], to another char *array[i], ( the result suggests so )
thanks in advance
BujarM
Last edited by BujarM; 04-19-2009 at 03:55 PM.
I've written client server stuff for linux but I won't even look* at this until you do a better job of summarizing your real problems and asking specific questions. For example:
Sounds like a very basic issue you could test yourself, and then post <10 lines of code to represent your difficulty. But if you are too lazy, what makes you think someone else will scan through a few hundred lines of TOTALLY IRRELEVANT detail to sort this now very very vague statement out??Code:1) assigning a normal char array[], to another char *array[i], ( the result suggests so )
Good luck.
*relax, someone else might!
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
you make a good point, but i already covered this
i did test it in VS and GCC, and it works
thats why im soo confused,
i am just hoping someone with more experience
can point out my errors
Code:#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { while(1) { char *client_balance[]={"20000", "18000", "16000", "14000", "12000"}; int client_num=2; char buf[256]; printf("Please type the new BALANCE:"); fgets(buf,256,stdin); buf[6]='\0'; printf("%s\n", buf); client_balance[client_num]=buf; printf("%s\n",client_balance[client_num]); } system("PAUSE"); return 0; }
Last edited by BujarM; 04-19-2009 at 03:32 PM.
Okay, there are a few problems with your last post. They may or may not relate to your problem, but they do represent either a significant misunderstanding of some fundamentals, or some slightly bizarre methodology:
- fgets adds a '\0'; you don't have to (or is this intended to curtail the size of the input?)
- buf[6] is the seventh element of buf (counting from 0), and the items in client_balance are 5+1=6 (this is okay, since you are swapping pointers and not copying; I just wanted to make sure you get that -- otherwise why curtail the input at 6?).
But I don't see anything wrong with:
Why don't you post a small chunk of your Original Post containing the code which parallels this problem and explain what you mean by "the results suggest a logical bug" (I haven't compiled it and I won't be; sorry).Code:client_balance[client_num]=buf;
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
i am restricting the length to 6, i.e. end the buffer manually
when dealing with large amounts of code to debug in a command-line compiler,
you tend to be safe, than sorry.( :/ )
thank you for confirming this
i totally understand, i know its too many lines of code
i think im going to proceed alone and correct the code
thanks.....