Thread: Array of pointers little help :S

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    24

    Array of pointers little help :S

    See the attached picture and help me to make that damn algorithm I do not know how to type it in C.

    Code:
    char *m[] = {"data", "come", "here"};
    p = position = 0

    how to access that "data" and "come" i have lib for they color if I click right arrow background color of come must be become like green but i dont know how to access them...


    Thanks in advanced!

  2. #2
    Registered User
    Join Date
    Jul 2010
    Posts
    33
    Quote Originally Posted by westony View Post
    how to access that "data" and "come" i have lib for they color if I click right arrow background color of come must be become like green but i dont know how to access them...
    I do not understand this sentence. May you reiterate it?

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    OK I will try with code:

    I have to make APP like Turbo Pascal I draw menus and everything. To make some selection i have to REcolor the menu if you navigate in any menu you see that selected one is becoming dark blue or other color so i need to do the same thing. If my user push RIGHT ARROW need to make "data" back to normal color and "comes" blue so i am making it with this:

    Code:
    mainchInfo[i].Attributes = BACKGROUND_RED;
    where "i" is the position on my desktop
    if i = 0 i = "d" if i =1 = "a" .... etc

    so how when i press right arrow to change the color of my menu all code is done but that one with the colors ... so help me to "navigate" in this array of pointers

  4. #4
    Registered User
    Join Date
    Jul 2010
    Posts
    20
    Code:
    char *m[] = {"data\0", "come\0", "here\0"};
    
    for (p=0; p<3; p++) printf("%s\n", m[p]);

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    sorry but i dont wanna print the menu ...

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    So what is so difficult?
    m[0] is "data", m[1] is "come", m[2] is "here".
    Also, even though you don't know English well, put dots and commas in proper places to separate your sentence!
    It makes it much easier to read.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Sorry but, I can not use this m[0] I must do it pixel by pixel, thats mean that i must do it symbol by symbol

  8. #8
    Registered User
    Join Date
    May 2010
    Posts
    74
    You want to access each character? like m[0][0] ?

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It still doesn't make sense. You can simply use m[your_variable_here] which you fill in according to your needs.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Ohhh guys for printing my menu I am using this code:

    Code:
    	// printing top RED background
    
    	do
    	{
    		mainchInfo[j].Char.AsciiChar = ' ';
    		mainchInfo[j].Attributes = BACKGROUND_RED | BACKGROUND_INTENSITY;
    		j++;
    	}while(j < 80);
    
    	// printing top menu
    	do
    	{
    		for(i = 0; i < strlen(menu[u]); i++)
    		{
    			mainchInfo[k].Char.AsciiChar = *(menu[u] + i);
    			k++;
    		}
    		u++;
    		mainchInfo[k].Char.AsciiChar = ' ';
    		k++;
    	}while(u < count);
    
    	put_screen(&coord, mainchInfo);
    I need code like this for making that background changing colors ...

    So I ask how to make when my selection is on data to switch it to next element of array of pointers, I need a algorithm if i am on 3rd one how to switch to 4th one ... and in backward

    Hope now I am clear ...

  11. #11
    Registered User
    Join Date
    Jul 2010
    Posts
    20
    Add 1 to your pointer, or subtract 1.

  12. #12
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    yes man i know how to type it but this time i dont have the algorithm ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Returning an Array of Pointers to Objects
    By randomalias in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2006, 02:45 PM
  2. two-dimensional dynamic array of pointers to classes
    By Timo002 in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 06:18 AM
  3. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM
  4. array of pointers to struct array
    By eth0 in forum C++ Programming
    Replies: 1
    Last Post: 01-08-2004, 06:43 PM
  5. array of pointers to structs
    By stumon in forum C Programming
    Replies: 7
    Last Post: 03-24-2003, 07:13 AM