CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

choice of two arrays with pointer - how can it be?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Josszy



Joined: 17 Oct 2010
Posts: 4

View user's profile Send private message

choice of two arrays with pointer - how can it be?
PostPosted: Mon Jul 16, 2018 7:08 am     Reply with quote

I would like my program to write the texts in two languages so that I can specify a variable with the variable which is the current language.
The Hungarian and English language texts are stored in a single 'char const' array, and I want to solve the script with a pointer. Unfortunately, I have no practice in the pointer address syntax, so please help me.
I copy a sketch of a program outline here, with question marks for me "dark" parts. (now i'm all pretty "dark"). Embarassed Crying or Very sad
I apologize for my weak English knowledge ....

Code:

//----definition of variables----
.
.
char char_kiiras1[22]; //display text
int nyelv; // language variable
.
.
.
//----nyelvi konstansok-------
char *muvkiir[32]; // ?? pointer, this is done by making a reference (with an element number)
.
char const muvkiir_hun[32][22] = {{"Hibajelentes"},{"PUTD HIBA!"},{"SETUP vetel HIBA!"},{"Kilep"},…}; // Hungarian text (32-element array)

char const muvkiir_eng[32][22] = {{"Error report"},{"PUTD ERROR"},{"SETUP rec. ERROR!"},{"Exit "},…}; // English text (32-element array)
.
.
.
void main() {
   .
   //--- Set language texts (nyelv = 0 Hungarian, nyelv = 1 English)---
   if(nyelv==0) {
      ??????;
   }
   else {
      ??????;
   }
   .
   .
   .
strcpy(char_kiiras1,muvkiir[18]);      //preparation of text “Beallitasok” or “Set” (18. element)
.
.
.
glcd_text57(28, 6, char_kiiras1, 1, ON);        // Display "Beallitasok" or „Set” text
.
.

}

_________________
Josszy
temtronic



Joined: 01 Jul 2010
Posts: 9253
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jul 16, 2018 11:14 am     Reply with quote

Others will offer their suggestion..
here's mine
Make ONE 64 element array, where [0] is the 1st msg, in hung and [1] is the 1st msg in eng. repeat 31 more times.
When lang=0, add 0 to the 'msg offset' value. When lang=1, add 1 to the 'msg offset' value.
The msgs are in 'pairs'..same msg, 2 languages, repeated 32 times.
This 'should' work, I think...

Should be easy to try...
Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19562

View user's profile Send private message

PostPosted: Mon Jul 16, 2018 11:19 am     Reply with quote

Or just join the two arrays into a single 3 dimensional array. Make the third dimension '0' for the first language and '1' for the second...
Josszy



Joined: 17 Oct 2010
Posts: 4

View user's profile Send private message

PostPosted: Mon Jul 16, 2018 11:36 am     Reply with quote

Temtronic, thank you, your suggestion is super, and in any case simpler than the "play with the pointer"
I try to make the 'msg offset' variable simpler to use (elements of the 'muvkiir' array are used in more than 100 locations in the program ...)
Thanks again for the idea! Smile
_________________
Josszy
Josszy



Joined: 17 Oct 2010
Posts: 4

View user's profile Send private message

PostPosted: Mon Jul 16, 2018 11:40 am     Reply with quote

Ttelmah, that's a good idea, thank you! Smile
_________________
Josszy
Josszy



Joined: 17 Oct 2010
Posts: 4

View user's profile Send private message

PostPosted: Mon Jul 16, 2018 4:03 pm     Reply with quote

Temtronic, I did it and it works perfectly. Thanks once again! Smile
_________________
Josszy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group