barebones c char pointer

77 views Asked by At

So I have been trying to dive a bit into os development, and got to the point where I can execute c (with gcc).

char* parameter = "test"
videoMemory[1] = *parameter;
videoMemory[2] = 0xcf;

When I execute the code I get nothing printed out except the red background (0xcf refers to foreground and background colors). I have also tried

videoMemory[1] = parameter[0];

and got nothing. When executing

videoMemory[1] = 'X';

or

videoMemory[1] = "test"[0];

I get the X character printed out. What do I have to do to get the string stored in the variable 'parameter' printed to the screen

*edit: link to project [https://drive.google.com/file/d/1D1xgfbL1uY7zY48Nm-x6QNvZOhh713n1/view?usp=sharing]

SOLVED I have solved the issue. I used char stringarray[] = "", and it works just as expected

1

There are 1 answers

0
codyne On

You want to assign an individual character to the address in memory, like you did with X but you need to do it at the correct location.

videoMemory[0] = 'X'; and at videoMemory[1] is where you would put color data about the character (if any) If you want to add a second character, you would do so at index 2 like videoMemory[2] = 'Y';

To print out whole strings to the video memory, you will need to write a function, or set of functions, which keeps track of the position of the cursor on the screen, goes through each character in the string printing to the position of the cursor while advancing it each time.