<< < 6 7 8 9 10 11 12 13 14 15 16 > >>   Sort: Date

What does it mean when the linker says that _end is undefined?
What does it mean when the linker says that _end is undefined? That message is a quirk of the old Unix linkers. You get an error about _end being undefined only when other symbols are undefined, too--fix the others, and the error about _end will disappear.
2015-07-06, 1156👍, 0💬

How can a process change an environment variable in its caller?
How can a process change an environment variable in its caller? It may or may not be possible to do so at all. Different operating systems implement global name/value functionality similar to the Unix environment in different ways. Whether the ``environment'' can be usefully altered by a running pro...
2015-03-11, 1156👍, 0💬

I need some code to do regular expression and wildcard matching.
I need some code to do regular expression and wildcard matching. Make sure you recognize the difference between: * Classic regular expressions, variants of which are used in such Unix utilities as ed and grep. In regular expressions, a dot . usually matches any single character, and the sequence .* ...
2015-08-12, 1155👍, 0💬

I am trying to sort an array of strings with qsort, using strcmp as the comparison function, but it is not working.
I am trying to sort an array of strings with qsort, using strcmp as the comparison function, but it is not working. By ``array of strings'' you probably mean ``array of pointers to char.'' The arguments to qsort's comparison function are pointers to the objects being sorted, in this case, pointers t...
2015-08-12, 1155👍, 0💬

I am trying to compile this program
I'm trying to compile this program, but the compiler is complaining that ``union REGS'' is undefined, and the linker is complaining that int86 is undefined. Those have to do with MS-DOS interrupt programming. They don't exist on other systems.
2015-03-02, 1154👍, 0💬

I am getting strange syntax errors inside lines I have ifdeffed out.
I am getting strange syntax errors inside lines I have ifdeffed out. Under ANSI C, the text inside a ``turned off'' #if, #ifdef, or #ifndef must still consist of ``valid preprocessing tokens.'' This means that the characters " and ' must each be paired just as in real C code, and the pairs mustn't c...
2015-12-14, 1153👍, 0💬

Where can I get an ANSI-compatible lint?
Where can I get an ANSI-compatible lint? Products called PC-Lint and FlexeLint are available from Gimpel Software. The Unix System V release 4 lint is ANSI-compatible, and is available separately (bundled with other C tools) from UNIX Support Labs or from System V resellers. Another ANSI-compatible ...
2015-05-05, 1153👍, 0💬

How can I tell how much destination buffer space ...
How can I tell how much destination buffer space I'll need for an arbitrary sprintf call? How can I avoid overflowing the destination buffer with sprintf? When the format string being used with sprintf is known and relatively simple, you can sometimes predict a buffer size in an ad-hoc way. If the f...
2015-10-19, 1151👍, 0💬

How can I return multiple values from a function?
How can I return multiple values from a function? There are several ways of doing this. (These examples show hypothetical polar-to-rectangular coordinate conversion functions, which must return both an x and a y coordinate.) 1. Pass pointers to several locations which the function can fill in: #incl...
2015-02-25, 1151👍, 0💬

This program crashes before it even runs!
This program crashes before it even runs! (When single-stepping with a debugger, it dies before the first statement in main.) You probably have one or more very large (kilobyte or more) local arrays. Many systems have fixed-size stacks, and even those which perform dynamic stack allocation automatic...
2015-05-29, 1149👍, 0💬

What is the ANSI C Standard?
What is the ANSI C Standard? In 1983, the American National Standards Institute (ANSI) commissioned a committee, X3J11, to standardize the C language. After a long, arduous process, including several widespread public reviews, the committee's work was finally ratified as ANS X3.159-1989 on December ...
2016-01-15, 1148👍, 0💬

If you cant modify string literals, why arent they defined as being arrays of const characters?
If you cant modify string literals, why arent they defined as being arrays of const characters? One reason is that so very much code contains lines like char *p = "Hello, world!"; which are not necessarily incorrect. These lines would suffer the diagnostic messages, but it's really any later attempt...
2016-01-06, 1148👍, 0💬

I am having trouble with a Turbo C program which crashes
I'm having trouble with a Turbo C program which crashes and says something like ``floating point formats not linked.'' Some compilers for small machines, including Turbo C (and Ritchie's original PDP-11 compiler), leave out certain floating point support if it looks like it will not be needed. In pa...
2015-06-19, 1148👍, 0💬

How can my program discover the complete pathname to the executable from which it was invoked?
How can my program discover the complete pathname to the executable from which it was invoked? argv[0] may contain all or part of the pathname, or it may contain nothing. You may be able to duplicate the command language interpreter's search path logic to locate the executable if the name in argv[0]...
2015-03-13, 1148👍, 0💬

How can I trap or ignore keyboard interrupts like control-C?
How can I trap or ignore keyboard interrupts like control-C? The basic step is to call signal, either as #include &lt;signal.h> signal(SIGINT, SIG_IGN); to ignore the interrupt signal, or as extern void func(int); signal(SIGINT, func); to cause control to transfer to function func on receipt of ...
2015-03-06, 1148👍, 0💬

My programs prompts and intermediate output dont always show up on the screen ...
My program's prompts and intermediate output don't always show up on the screen, especially when I pipe the output through another program. It's best to use an explicit fflush(stdout) whenever output should definitely be visible (and especially if the text does not end with \n). Several mechanisms a...
2015-11-11, 1147👍, 0💬

I have a simple little program that reads characters until EOF ...
I have a simple little program that reads characters until EOF, but how do I actually enter that ``EOF'' value from the keyboard? I see that EOF is defined by to be -1; am I supposed to enter -1? If you think about it, what you enter can't be -1, because ``-1'' is two characters, and getchar is read...
2015-11-16, 1146👍, 0💬

What are the differences between C and CPP?
What are the differences between C and CPP? Q: Is C++ a superset of C? What are the differences between C and C++? Can I use a C++ compiler to compile C code? A: C++ was derived from C, and is largely based on it, but there are some legal C constructs which are not legal C++. Conversely, ANSI C inhe...
2015-01-10, 1145👍, 0💬

I have got some code that is trying to unpack external structures
I've got some code that's trying to unpack external structures, but it's crashing with a message about an ``unaligned access.'' What does this mean? The code looks like this: struct mystruct { char c; long int i32; int i16; } s; char buf[7], *p; fread(buf, 7, 1, fp); p = buf; s.c = *p++; s.i32 = *(l...
2015-05-20, 1144👍, 0💬

How can I swap two values without using a temporary?
How can I swap two values without using a temporary? The standard hoary old assembly language programmer's trick is: a ^= b; b ^= a; a ^= b; But this sort of code has little place in modern, HLL programming. Temporary variables are essentially free, and the idiomatic code using three assignments, na...
2015-02-06, 1144👍, 0💬

Why is this loop always executing once?
Why is this loop always executing once? for(i = start; i &lt; end; i++); { printf("%d\n", i); } A: The accidental extra semicolon hiding at the end of the line containing the for constitutes a null statement which is, as far as the compiler is concerned, the loop body. The following brace-enclos...
2015-06-03, 1143👍, 0💬

How can I write a macro which takes a variable number of arguments ....
How can I write a macro which takes a variable number of arguments, or use the preprocessor to ``turn off'' a function call with a variable number of arguments? One popular trick is to define and invoke the macro with a single, parenthesized ``argument'' which in the macro expansion becomes the enti...
2016-01-19, 1142👍, 0💬

I came across some code that puts a (void) cast before each call to printf. Why?
I came across some code that puts a (void) cast before each call to printf. Why? printf does return a value (the number of characters printed, or an error code), though few programs bother to check the return values from each call. Since some compilers (and lint) will warn about discarded return val...
2015-05-13, 1142👍, 0💬

How can I do serial comm port I O?
How can I do serial (``comm'') port I/O? It's system-dependent. Under Unix, you typically open, read, and write a device file in /dev, and use the facilities of the terminal driver to adjust its characteristics.Under MS-DOS, you can use the predefined stream stdaux, or a special file like COM1, or s...
2015-04-22, 1142👍, 0💬

<< < 6 7 8 9 10 11 12 13 14 15 16 > >>   Sort: Date