Hi,
Have finally started on my C Kernel, I am after a tutorial that specifically teaches the use of C in OS design. The reason I want this is because I am having doing stuff in C that I can already do in asm. In asm I am have gone all the way up to having paging enabled and working properly, GDT, IDT all setup properly. This was where I got to when I decided that it was time to start coding my kernel properly. I could write it all in asm, but this is not going to be easy and it would take 10 times as long as it will to do it in C, all I need is some fundamental info on using C for OS coding.
With printf() I am wondering how I deal with multiple unknown amounts of args in C.
printf(char*, ...)
Re:printf(char*, ...)
Look at my printf in FritzOS, it was just released, it might help some, because it's not done yet...
you should look at the string handler in my printf...it can handle infinite string printing ( infinite %s's like this:
printf( "%s", "%s %s", "hello", "the end" ); like that, but it' can't handle infinte chars or numbers )
you should look at the string handler in my printf...it can handle infinite string printing ( infinite %s's like this:
printf( "%s", "%s %s", "hello", "the end" ); like that, but it' can't handle infinte chars or numbers )
Re:printf(char*, ...)
Tom: interesting idea -- but don't use your "infinite string" idea if you want to claim C compatibility. Otherwise, something like this would break:
Output:
[tt]Please type a percent sign and a letter:
%s
You typed: shioshgldfhd
!!!ERROR!!!
Page fault
DEATH
BLUE SCEEEN!!!!!!"1111[/tt]
Code: Select all
int main(void)
{
char percent_s[10];
/* This is a portable C program which will work under any OS */
printf("Please type a percent sign and a letter: (e.g. %%s)\n");
gets(percent_s);
printf("You typed: %s\n", percent_s);
}
[tt]Please type a percent sign and a letter:
%s
You typed: shioshgldfhd
!!!ERROR!!!
Page fault
DEATH
BLUE SCEEEN!!!!!!"1111[/tt]
Re:printf(char*, ...)
I tested my code every way...I don't see a error in it, or I don't under stand what you mean.
If you look at my code, it doesn't depend on how big the string is...
If you look at my code, it doesn't depend on how big the string is...
Re:printf(char*, ...)
My point is that everyone expects printf to be:
printf(string_containing_formatting_characters, some, strings, without, formatting, characters);
If you start putting formatting in the second parameter and beyond, you'll introduce unexpected behaviour. People don't expect these parameters to be treated specially.
printf(string_containing_formatting_characters, some, strings, without, formatting, characters);
If you start putting formatting in the second parameter and beyond, you'll introduce unexpected behaviour. People don't expect these parameters to be treated specially.