The best place to start is with your data structures.
Here it's quite simple. You need a struct with a single key / value pair, both strings. It probably mkaes sense to make them both char *s and...
Type: Posts; User: Malcolm McLean
The best place to start is with your data structures.
Here it's quite simple. You need a struct with a single key / value pair, both strings. It probably mkaes sense to make them both char *s and...
The goto cashier is suspicious and is probably the root of your problems.
rename "main" something else, and write a new temporary main.
This just opens a file for writing and writes some text...
Do you understand what is going on?
There are at least two standard IO implementations on your system.
When the MINNGW library is used, your macro is defined. It also happens to be defined to...
Do you mean one bit or one byte? Most computers address memory in 8 bit bytes. In C, and int is usually 4 bytes, or 32 bits.
A boolean variable is logically one bit, either on or off. However C...
free(ptr);
printf("\n\nFreeing ptr: \n");
/* not sure whether this is allowed or not. sizeof() is a compile
time operator rather than function, so it is probably OK */
...
A C program needs several memory areas. The executable code itself, the stack, the heap, and global data. Global data is usually then divided into read-only memory, initialised memory, and memory...
You need a buffer of three results. The easiest way to do this
is via a small array
char results[3];
initialise to some value which is neither heads nor tails, because you must toss the coin...
It's a mathematical problem rather than a programming problem, and certainly rather than a C problem.
An entire industry is based onthe premise that factoring large integer with large prime...
Use this interface
void zeroCrossings(const float *x, bool *crossings, int N);
The array crossings is the same length as the input array x, but each position represents the line between...
Should be fine. Almost certainly you have an error elsewhere
in the code. For example when printing the result out.
Undo is always difficult to program. The easiest way is to have a list of all previous states. Fortunately a tic-tac-toe board is only a few bytes, so there's no real issue in memory or performance....
Most beginners' C books introduce 2D arrays iimmediately after 1D arrays.
This is a mistake. Multidimensional arrays were historically not implemented well in C, and should be thought of as an...
Sort the list.
Since it's a linked list, you can't use qsort. Mergesort is a good linked list sort algorithm.
Now it's trivial to pick out the unique instances. A unique instance is either the...
The local variables in main are pushed first on to the stack. Notionally in the order in which they are declared, though the optimiser may make some changes and you can't rely on this if playing...
If you are new to programming, then it's best to work through a C primer using just the standard library to learn the core language, before tackling any SDK.
If you know some programming, C has...
We're not a free homework-doing service for people who have difficulty with their assignments.
You just ned some more complicated logic in your inner for loop.
The outer for loop iterates over the size of the input.
The inner for loop needs to output a series of dashes, followed by a varying...
In C, string are passed around as char *'s. They are arrays of char
terminated with a NUL. Since you have a buffer, you need to
call the function strcpy() to copy your input strings to this buffer....
You use fgets like this
char string[1024];
fgets(string, 1024, stdin);
User is very unlikely to enter 1024 characters. Probably you only expect 20 or so. But it's usually hard to give a...
If you're advanced enough to write a minesweeper game then you should be past the stage where people have to point out this type of bug in your code on the forum. Every C programmer gets segmentation...
structs are padded for alignment purposes. acctNum will be 4 bytes, lastName 16 (1 pad), firstname 12(2 pad) and balance 8 bytes.
You want to open the text file, as binary. Call fopen "rb".
When you compress it, you're not treating it as a text file any more. You're treating it as a sequence of bytes. Similarly, the...
If 6 means "roll again and add six" then this is impossible.
The object of the exercise seems to be to get the mean. This isn't entirely simple, and it's one of those things that is maybe easier...
You've got six lines. Then on each line you've got 1, 2, 3, 4, 5, 6 values.
So that bit is easy. Your skeleton is
for (i=0; i < 6; i++)
{
for (j = 0; j < 6; j++)
{
You should exit(EXIT_FAILURE); rather than with a constant to be portable. However most OSes don't have a strong concept of a process "failing". It can be hard to define for many real programs.