Constant Strings not working

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Locked
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Constant Strings not working

Post by Chandra »

Hello, I'm writing a 16 bit Dos like Operating System with GUI and Extended memory support. I prefer to begin from the very inital so I decided to write 16 bit O.S and then shift to writing 32 bit O.S. Other things apart, here's what i've strucked in.
I've writing printstring function similar to printf function which prints string to the video screen:
void printstring(const char input_string[50]
The problem is when i pass constants to my printstring function like this printstring("hello people"), then this function doesn't work but when i first initalize the string and then pass this argument to the printstring function like this,
char message[12]={"Hello People"};
printstring(message);
then everything goes fine.I tried using pointers but encountered same problem. I wonder if there's problem with initalization of segment registers in my bootloader. Please Help!
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Constant Strings not working

Post by Combuster »

Did you just ask a Frequently Asked Question?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Constant Strings not working

Post by Solar »

Perhaps we should rename that to "Frequently Answered Questions". :twisted:

What stuns me every time is how people seem to skip the debugging phase completely. The question always is "I write this code, and it doesn't work". The question never is "I write this code, and the string doesn't end up in the binary" or somesuch...
Every good solution is obvious once you've found it.
Locked