It's hard to answer because no-one would write a function to muliply a real value by two. It must be placeholder code.
If you are calculating one value, return it as a "double" (not a double *)....
Type: Posts; User: Malcolm McLean
It's hard to answer because no-one would write a function to muliply a real value by two. It must be placeholder code.
If you are calculating one value, return it as a "double" (not a double *)....
You can rewrite any loop as a set of recursive calls. There's a school of thought that you should do that. However not normally in C, but in a so-called "functional" programming language. Scheme is...
Some things you can fake up in C, other things you can't do without effectively writing an interpreter for another language in C. The main C limitation versus C++ that can't be overcome is the lack...
It's very nearly an executable file. It's compiled machine code with labels attached. So you can't actually run it. However it's relatively simple to replace the labels with addresses (linking) and...
University professors shouldn't give exercises like this.
C doesn't have good facilities for parsing input. You have to write from scratch on the top of low level functions. To do a really solid...
Change making is a difficult problem. It's usually easy to find a trivial solution (all units), and a better algorithm (take the highest note and subtract until you can do no more, then repeat with...
int main(void)
{
int array[5] = {2, 4, 6, 1, 5};
int j, k;
for (j =0; j < 5; j++)
for (k = 0; k < 5; k++)
{
char compare;
if (array[j] < array[k])
Yes. You need to know what font your output device is using.
Standard C has no functions for querying a font, but your platform will. Since getting the width of a string is such a common...
Unless someone here has the exact same system, they can only speculate. One possibility which has been mentioned is that char_array2 is a pointer, in which case sizeof() will yield a value of...
It's not quite clear what you want to do. But say we want 1 to represent 'a' and 26 to represent 'z', and we want to write to a string at a position, we can write a function like this
void...
The way I would do it is to take a list of filenames on the commandline, open them, and write the contents to stdout.
Basically the Unix "cat" command.
User can then do what he wants with the...
The days when you had to pay for a compiler are over. Visual Studio is free, and is a highly capable C++ (and therefore C) compiler.
Here's the old Windows file API
Fileapi.h header - Win32...
If parent_t contains a pointer to a child_t rather than an instance of a child_t, then you have to create the memory space for the child_t somehow. That can be by using malloc, or if you don't want...
So if the absolute value is greater than two you repeatedly divide by two, otherwise you repeatedly multiply by two, until you have a number in the form 1.xxxxxx. The number of steps gives you the...
The answer is to use the frexpf() function to decompose a float into exponent and mantissa. Internally it will be doing bit shifting and masking and you can write your own version on similar...
You want to work with a copy of the command line argument. It's
not a good idea to modify the argv[] strings in place.
So call malloc() with strlen(argv[1]) + 1 (for the nul), then strcpy....
Open GL is the the obvious one.
Getting Started - OpenGL Wiki
Matrices can be hard to understand. It's easier when you think of them as something concrete rather than an abstract "matrix". When I'm teaching matrices, I use football as an example. Say you've got...
Start with the function isvowel(char ch) that tells you whether a character is a vowel or not. Then build countvowels(char *str) on top of it.
That's the logic for you program.
Now the hard part is...
define two macros. One is uniform(), which create a random number on 0-1. The other is lerp, which interpolates between a and b by paramter t, on 0-1.
So
x = lerp(-1.0, 1.0, uniform());
...
I don't think that's a good idea. It's best to write your own tar attempt first, then worry about how the actual tar implementation does it later.
Tar collapses a directory into one file. A...
Computers can run out of memory. But if you are making valid allocations in a small beginner's program on a desktop machine, this is very unlikely.
You need to test the return from realloc() for...
It's really a signals processing issue rather than a C issue.
The body of the sound (dot dash) can be either a pure sine wave or a combination of sine waves. In a real application you would...
UTF-8 is backwards compatible with ascii, which is a huge advantage. UTF-16 has the disadvantage that it can't represent some code points, whilst UTF-32 is rather extravagant if most of the text is...
C strings are terminated by 0 (nul), not newline.
In C, strings are basically just arrays of 8 bit ascii values arranged in memory. There's jsut a little bit of special syntax to allow you to...