OK so I was experimenting with the gfx_printstringxy(char* str, etc...)
I realized that I wanted to print a char array. So I passed a pointer:


gfx_printstringxy(&arr, 100, 10);

This caused the text to be printed weirdly. Big and with the lines through it. I know there is print char, in which you loop through the values. Is that how I'm supposed to print the array?
An char array (a string) decays to a char pointer, so just:
gfx_PrintStringXY(arr, 100, 10)

Also, please read the documentation in the future, it should be able to answer most of these questions for you.

EDIT: While this is true, it likely isn’t what you’re looking for. Commandblockguy’s solution is the correct one.
Are you calling gfx_Begin first? All of the graphx commands will display funny if you don't do that first, as the OS uses a different bits-per-pixel mode than graphx does. You'll also need to call gfx_End before exiting to clean up.
Yeah I did exactly what you did. Idk what happen. Though this is the exact code (without the includes):


int main() {
    int x = 0;
    char work[10];
    sprintf(work, "some %d", x);
    gfx_PrintStringXY(&work, 100, 130);
    //if I do gfx_PrintStringXY(work, 100, 130); it gives me gibberish.

This is probably a debugging error, but thanks for the replies. I'm pretty new to this (i've done c++, java, python, but not that much c) I'll work on this later, I probably did some stuff wrong. Oh. I'll try running gfx_printStringXY(work, 100, 130); later. I think I know the problem.
It's probably actually the puts that's creating the gibberish text - I believe puts expects the graphics to be in the mode the OS uses, rather than the one graphx uses. So, I would either remove the gfx_Begin and only use puts, or keep the gfx_Begin and remove the puts call.
Yeah thanks. I removed the puts and it seemed to work. I'm new to c so I just copied that code somewhere else "how to make int a string in c". Should have researched what puts does. Turns out its a weird print function. I usually use higher leveled langauges. Man its though doing string manipulation in c. In java use "some " + x. In cpp use "some " + std::to_string(x) and in python "some " + str(x). Not used to using strcat and sprinf
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
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