I'm in the process of coding my own OS and right now I'm working on a stdio lib but was just wondering about fputs and how it should write to the screen, which would be a better approach? Making stdout a file descriptor and having puts call fputs with the file descriptor, or should I have stdout as a flag and an if statement in fputs to catch stdout and call puts?

Trivial question really, but I just wonder what would be the preferred approach I guess.

What will you do when stdout is redirected to a file? The file descriptor approach is conventional, and your flag idea seems awkward at best. There will be a lot of special cases with the flag while a file descriptor just works naturally.

I guess I'll go with the file descriptor then if it's the conventional method, I hadn't really thought about anything other than the screen as I haven't got hard drive support yet, I do however have support for an initial ramdisk so I can at least play around on screen.

Is there any documentation on this sort of thing? I always feel I'm cheating myself if I look at other peoples code but I would like to stay as standard as I can to keep things portable.

>Is there any documentation on this sort of thing?
There's documentation on stdio, for sure. But the actual implementation is up to the implementor. If you want to know how people usually do it, their code is the best way to go about it.

I guess I'll get as much done as I can for now and if I have anything I find questionable I'll peek at someone else's code to gleam some information.

Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.