简体   繁体   中英

Retrieve a char from a char array

Does anyone know how to retrieve a char value from a char array:

char* alphaChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

for (int rowIndex = 0; rowIndex < 12; rowIndex++) 
{
    char* text = (char*)alphaChars[0]; //this throws an error

    //CGContextShowTextAtPoint(context, 10, 15, text, strlen(text)); //This is where I wanna use it
}

If you just want one character, you don't want to assign it to a pointer:

char text = alphaChars[0];

Then you would call your next function:

CGContextShowTextAtPoint(context, 10, 15, &text, 1);

If you want the whole string, which is sort of what your code looks like it's doing, you don't need to have an intermediate variable at all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM