- Home
- Interview Questions
- C Programming
You can write a C program to do this, but it won't work. For example, if you try to use stdprn with fscanf(), the program compiles into an executable file, but the printer is incapable of sending input, so your program doesn't operate as intended.
Most compilers have a Library Function Reference manual or section. This manual or section of a manual lists all the compiler’s library functions and how to use them. Usually, the manual includes information on the compatibility of the function. Sometimes, the descriptions state not only whether the function is ANSI-compatible, but also whether it is compatible with DOS, UNIX, Windows, C++, or OS/2.
Most compilers come with many useful functions that aren’t ANSI-standard. If you plan on always using that compiler and not porting your code to other compilers or platforms, there won’t be a problem. If you’re going to use other compilers and platforms, you should be concerned with ANSI compatibility.
If you're using the standard output or input streams, you should use printf() and scanf(). By using these simpler functions, you don't have to bother with any other streams.
You need to check your compiler manuals to determine whether there are any limitations. There is rarely any reason to go more than three levels deep with pointers (pointers to pointers to pointers). Most programs rarely go over two levels.
No. A string can be considered an array of characters.
Yes. You can also read before the beginning of a file. Results from such reads can be disastrous. Reading files is just like working with arrays. You’re looking at offsets within memory. If you’re using fseek(), you should check to make sure that you don’t go beyond the end of the file.
Yes. Pointers to functions also are used with menus. Based on a value returned from a menu, a pointer is set to the function that should be called based on the menu choice.
One: The size of a linked list can be increased or decreased while the program is running; it doesn’t have to be predefined when you write the code. Two: It’s easy to keep a linked list in sorted order, because elements can easily be added or deleted anywhere in the list.
Yes. You can use a full filename with a path and a drive or just the filename by itself. If you use the filename by itself, the function looks for the file in the current directory. Remember, when using a backslash (\), you need to use the escape sequence. Also remember that UNIX uses the forward slash (/) as a directory separator.