<< < 8 9 10 11 12 13 14 15 16 17 18 > >>

How can I access an I O board directly?
How can I access an I O board directly? At one level, at least, it's quite simple: you have a device register which is actually wired up so that the bits written to it get coverted to actual voltage levels in the real world that you can do interesting things with. In general, there are two ways to g...
2015-04-20, 1126👍, 0💬

How can I do graphics?
How can I do graphics? Once upon a time, Unix had a fairly nice little set of device-independent plot functions described in plot(3) and plot(5). The GNU libplot library, written by Robert Maier, maintains the same spirit and supports many modern plot devices; see http://www.gnu.org/software/pl otuti...
2015-04-17, 1119👍, 0💬

How can I send mail from within a C program?
How can I send mail from within a C program? Under Unix, open a pipe to the mail program, or perhaps /usr/lib/sendmail.
2015-04-17, 1128👍, 0💬

How can I check whether a file exists? I want to warn the user if a requested input file is missing.
How can I check whether a file exists? I want to warn the user if a requested input file is missing. It's surprisingly difficult to make this determination reliably and portably. Any test you make can be invalidated if the file is created or deleted (i.e. by some other process) between the time you ...
2015-04-15, 1124👍, 0💬

How can I find out the size of a file, prior to reading it in?
How can I find out the size of a file, prior to reading it in? If the ``size of a file'' is the number of characters you'll be able to read from it in C (or which were written to it by a previous program), it can be difficult or impossible to determine this number exactly (other than by reading the ...
2015-04-15, 1110👍, 0💬

How can I find the modification date and time of a file?
How can I find the modification date and time of a file? The Unix and POSIX function is stat, which several other systems supply as well.
2015-04-13, 1122👍, 0💬

How can I insert or delete a line (or record) in the middle of a file?
How can I insert or delete a line (or record) in the middle of a file? In general, there is no way to do this. The usual solution is simply to rewrite the file. When you find yourself needing to insert data into an existing file, here are a few alternatives you can try: * Rearrange the data file so ...
2015-04-13, 1077👍, 0💬

How can I recover the file name given an open stream or file descriptor?
How can I recover the file name given an open stream or file descriptor? This problem is, in general, insoluble. Under Unix, for instance, a scan of the entire disk (perhaps involving special permissions) would theoretically be required, and would fail if the descriptor were connected to a pipe or r...
2015-04-10, 1231👍, 0💬

How can I delete a file?
How can I delete a file? The Standard C Library function is remove. (This is therefore one of the few questions in this section for which the answer is not ``It's system-dependent.'') On older, pre-ANSI Unix systems, remove may not exist, in which case you can try unlink.
2015-04-10, 1034👍, 0💬

How do I copy files?
How do I copy files? Either use system() to invoke your operating system's copy utility, or open the source and destination files (using fopen or some lower-level file-opening system call), read characters or blocks of characters from the source file, and write them to the destination file. Here is ...
2015-04-08, 1175👍, 0💬

Why cant I open a file by its explicit path?
Why can't I open a file by its explicit path? The call fopen("c:\newdir\file.dat", "r") is failing. The file you actually requested--with the characters \n and \f in its name--probably doesn't exist, and isn't what you thought you were trying to open. In character constants and string literals, the ...
2015-04-08, 1140👍, 0💬

fopen isnt letting me open files like "$HOME/.profile" and "~/.myrcfile".
fopen isn't letting me open files like "$HOME/.profile" and "~/.myrcfile". Under Unix, at least, environment variables like $HOME, along with the home-directory notation involving the ~ character, are expanded by the shell, and there's no mechanism to perform these expansions automatically when you ...
2015-04-06, 1225👍, 0💬

How can I suppress the dreaded MS-DOS Abort, Retry, Ignore? message?
How can I suppress the dreaded MS-DOS Abort, Retry, Ignore? message? Among other things, you need to intercept the DOS Critical Error Interrupt, interrupt 24H. See the comp.os.msdos.programmer
2015-04-06, 1179👍, 0💬

How can I increase the allowable number of simultaneously open files?
I'm getting an error, ``Too many open files''. How can I increase the allowable number of simultaneously open files? A: There are typically at least two resource limitations on the number of simultaneously open files: the number of low-level ``file descriptors'' or ``file handles'' available in the ...
2015-04-03, 1181👍, 0💬

How can I find out how much free space is available on disk?
How can I find out how much free space is available on disk? There is no portable way. Under some versions of Unix you can call statfs. Under MS-DOS, use interrupt 0x21 subfunction 0x36, or perhaps a routine such as diskfree. Another possibility is to use popen to invoke and read the output of a ``d...
2015-04-03, 1070👍, 0💬

How can I read a directory in a C program?
How can I read a directory in a C program? See if you can use the opendir and readdir functions, which are part of the POSIX standard and are available on most Unix variants. Implementations also exist for MS-DOS, VMS, and other systems. (MS-DOS also has FINDFIRST and FINDNEXT routines which do esse...
2015-04-01, 1173👍, 0💬

How do I create a directory? How do I remove a directory (and its contents)?
How do I create a directory? How do I remove a directory (and its contents)? If your operating system supports these services, they are likely to be provided in C via functions named mkdir and rmdir. Removing a directory's contents as well will require listing them and calling remove . If you don't ...
2015-04-01, 1151👍, 0💬

How can I find out how much memory is available?
How can I find out how much memory is available? Your operating system may provide a routine which returns this information, but it's quite system-dependent. (Also, the number may vary over time.) If you're trying to predict whether you'll be able to allocate a certain amount of memory, just try it-...
2015-03-30, 1219👍, 0💬

How can I allocate arrays or structures bigger than 64K?
How can I allocate arrays or structures bigger than 64K? A reasonable computer ought to give you transparent access to all available memory. If you're not so lucky, you'll either have to rethink your program's use of memory, or use various system-specific techniques. 64K is (still) a pretty big chun...
2015-03-30, 1157👍, 0💬

I thought that using large model meant that I could use more than 64K of data!
What does the error message ``DGROUP data allocation exceeds 64K'' mean, and what can I do about it? I thought that using large model meant that I could use more than 64K of data! Even in large memory models, MS-DOS compilers apparently toss certain data (strings, some initialized global or static v...
2015-03-20, 1115👍, 0💬

How can I do PEEK and POKE in C?
How can I access memory (a memory-mapped device, or graphics memory) located at a certain address? How can I do PEEK and POKE in C? Set a pointer, of the appropriate type, to the right number (using an explicit cast to assure the compiler that you really do intend this nonportable conversion): unsig...
2015-03-20, 1158👍, 0💬

How can I invoke another program (a standalone executable, or an operating system command) from within a C program?
How can I invoke another program (a standalone executable, or an operating system command) from within a C program? Use the library function system, which does exactly that. Some systems also provide a family of spawn routines which accomplish approximately the same thing. system is more ``portable'...
2015-03-18, 1180👍, 0💬

How can I call system when parameters (filenames, etc.) of the executed command arent known until run time?
How can I call system when parameters (filenames, etc.) of the executed command arent known until run time? Just use sprintf (or perhaps strcpy and strcat) to build the command string in a buffer, then call system with that buffer. (Make sure the buffer is allocated with enough space; Here is a cont...
2015-03-18, 1178👍, 0💬

How do I get an accurate error status return from system on MS-DOS?
How do I get an accurate error status return from system on MS-DOS? You can't; COMMAND.COM doesn't tend to provide one. If you don't need COMMAND.COM's services (i.e. if you're just trying to invoke a simple program, without I/O redirection and such) try one of the spawn routines, instead.
2015-03-16, 1182👍, 0💬

<< < 8 9 10 11 12 13 14 15 16 17 18 > >>