We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Please. I try to write in C my old assembler program amd dont know how to overcom the next.
In assembler it is possible to write label_A: ; ....any... dw label_A ; dw label_B ; label_B: ; ....any...
But in C the equivalent code char code item1 [ 17 ] = "aaa"; void* code ref1 = &item1; void* code ref2 = &item2; char code item2 [ 17 ] = "bbb"; gives Error C202 'item2': undefined identifier
Would somebody direct me? Thanks in advance. Yury.
It is me again. I found a wrong outlook of my message try:
In assembler it is possible to write label_A: ; ....any... dw label_A ; dw label_B ; label_B: ; ....any... But in C the equivalent code char code item1 [ 17 ] = "aaa"; void* code ref1 = &item1; void* code ref2 = &item2; char code item2 [ 17 ] = "bbb"; gives Error C202 'item2': undefined identifier
Are you trying to do something like:
char* labels[] = {"First label","Second label",0};
or
char data[3][20] = {"Value1","Value2","Value3"}; ... strcpy(data[2],"New value 3");
"I try to write in C my old assembler program"
I think you are taking the wrong approach!
You are looking at how you did it in assembler, and trying to replicate that in 'C'. This is not (generally) a good idea - 'C' and assembler work in different ways.
A far better approach would be to look at what your assembler code does, and then think about how to achieve that same outcome in 'C'.
Obviously, this requires that you know both 'C' and assembler.
If you are just starting with 'C', I suggest that you leave this, and concentrate on learning the language first. Once you have learned the 'C' language, then you can apply it to this problem!
"gives Error C202 'item2': undefined identifier"
And so it should - the definition of 'item2' needs to come before any reference to it!
But why are you using 'void*' ?
Why do you need pointers to the arrays - you can just use the array names!
As I suggested elsewhere, it looks like you need to take the time to learn the 'C' language first...
Hello guys. I have solved my own problem. My solve is not the best, but ir works. May be somebody knows any more elegant way? I would be thankful. Yury
May be somebody knows any more elegant way?
Exactly how would we be able to suggest a more elegant solution, when we don't know exactly what you are trying to do, and what your solution looks like?
"May be somebody knows any more elegant way?"
As Per said, this is impossible to answer without knowing what your "inelegant" way is!
However, as I said before, what you really need to do is to learn to write 'C' programs in 'C' - not to just use 'C' as a glorified assembler.
There is an old joke that says, "A Real Programmer can write FORTAN in any language!" :-0