Home
111.
What happens if I try to get input from an output stream?

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.

112.
How do I know whether a function is ANSI compatible?

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.

113.
Is there any danger in using non-ANSI functions in a program?

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.

114.
Why shouldn’t I always use fprintf() instead of printf()? Or fscanf() instead of scanf()?

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.

115.
How many levels deep can I go with pointers to pointers?

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.

116.
Is there a difference between a pointer to a string and a pointer to an array of characters?

No. A string can be considered an array of characters.

117.
Can I read beyond the end of a file?

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.

118.
Are there other times when function pointers are useful?

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.

119.
Name two major advantages of linked lists.

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.

120.
Can I use drives and paths with filenames when using remove(), rename(), fopen(), and the other file functions?

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.