LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   ironing out the bugs in my kernel--need make few functions-dont know how they work (https://www.linuxquestions.org/questions/programming-9/ironing-out-the-bugs-in-my-kernel-need-make-few-functions-dont-know-how-they-work-759281/)

smeezekitty 10-02-2009 04:23 PM

ironing out the bugs in my kernel--need make few functions-dont know how they work
 
ok i have my kernel booting loading and printing on screen
now i need to make fscanf, sscanf and sprintf
does anybody know how they work

orgcandman 10-02-2009 06:43 PM

They use varargs.

There's a pretty famous example. In fact, you might even be able to google the following phrase

Quote:

Wirzenius wrote this portably, Torvalds XXXXed it up
Note: XXXX is substituted for an expletive beginning with the letter f.

smeezekitty 10-02-2009 06:48 PM

Quote:

Wirzenius wrote this portably, Torvalds XXXXed it up
Note: XXXX is substituted for an expletive beginning with the letter f.
is that a joke!?

orgcandman 10-02-2009 06:49 PM

http://www.google.com/#hl=en&q=Wirze...15299a959dbb33

2nd link in google goes to vsprintf.c

smeezekitty 10-02-2009 07:14 PM

LHOL
now i have another problem with the code
vsprintf.c needs strnlen but i dont even know what it does much less have it in the kernel

lutusp 10-02-2009 08:04 PM

Quote:

Originally Posted by smeezekitty (Post 3705628)
LHOL
now i have another problem with the code
vsprintf.c needs strnlen but i dont even know what it does much less have it in the kernel

More programming by newsgroup?

Code:

$ man strnlen

smeezekitty 10-02-2009 08:41 PM

it doesnt work
i worked it into the kernel and it just freezes at the sprintf call
then i tried it out of the kernel still didnt work quite right

smeezekitty 10-02-2009 10:07 PM

here i will post my code:
Code:

#include <string.h>
#include <vsprintf.c>
extern void printf(char *, ...);
int main(){
char buffer[665];
sprintf(buffer, "hello world %d\n", 123);
printf("\n%s\n", buffer);
}


johnsfine 10-03-2009 06:58 AM

printf and all the things it calls directly or indirectly adds up to a lot of library routines.

From your other threads, I got the idea you were linking without standard libraries. Where are all those library functions coming from? If you let the (Turbo C) library functions into your link, it will be quite a bit of effort to catch and correct all the things that depend on DOS. If you don't, then the likely bugs are in the replacements you've coded for those library routines. Either way, posting your top level code is nearly useless.

Also, where did you get vsprintf.c? Is it a copy compatible with your 16 bit environment? Including a .c file in another .c file sometimes causes problems. I think you said you were using .cpp. Including a .c file in a .cpp is even more likely to cause problems.

smeezekitty 10-03-2009 11:42 AM

i ended up writing my own
still need to figure out the *scanf() functions


All times are GMT -5. The time now is 04:48 PM.