November 6th, 2012, 07:48 AM
I'm kind of new in C programming..
I'm trying to show a letter from "enum" acording to his index.
I didn't find a way to do this ;\
maybe u can figure out how to this..
the problem as u can see is in the last 6 lines..
November 6th, 2012, 09:16 AM
Yeah O.K., maybe you could elaborate what the problem is.
Originally Posted by shokshok
November 6th, 2012, 10:00 AM
Do not post your code in quote tags. Use code tags.
printf("%s\n%s\n", x_value=X, y_value=Y );
That is nearly gibberish. The results of those assignment expressions (in 23 years of C, I've never before seen anyone attempt to use an assignment expression as a printf argument) are int, which you are telling printf to interpret as strings. I'm not quite sure what exactly printf will do, but the result will be garbage. I think it might be interpreting those int values as pointers to where the strings are, in which case it goes to some random location in memory and interprets whatever data there as characters until it just happens to hit a zero byte.
enum's are basically identifiers for a sequence of integers starting with zero, unless you explicitly assign integer values to them. If you want to associate a particular string with an enum, the normal way would be to create an array of strings that you will then index with the enum. Another way might be to assign to the enum's their ASCII values and then printf an individual enum as a char (%c). I've used the former method and only just now thought of the latter.
November 6th, 2012, 11:39 AM