How would I use qsort? I don't really understand the structure of the code.
Type: Posts; User: MstrKurt
How would I use qsort? I don't really understand the structure of the code.
Hey i'm in need of a little bit of explanation how I can sort the records I write to a .txt document.
Here's my code:
FILE *fp1; //Declare pointer
...
Why am I wrong here?.
EDIT:
Or do you mean it's right to use == when using for example:
if(1==x) and
while(0==y)
But isn't right to say
Ok I have amended my code:
#include <stdio.h>
#include <string.h>
struct StockCtrl
{
int CatNum; // Declare Catalogue Number
Thanks for that advice, I will do that now :).
Ahhhh I see now. Thank you both for pointing that out.
I understand what you're saying, but you've got to remember that i'm looking for marks from what i've learnt currently.
I'm not saying you're wrong, i'm sure you're not, but i'm just trying to pass...
Thanks for the reply.
I understand that not everyone will agree with some of the code, maybe even all, but this is what i've been taught. Maybe at some later point I will be taught the difference...
#include <stdio.h>
#include <string.h>
struct StockCtrl
{
int CatNum; // Declare Catalogue Number
char title[20]; // Declare Book Title
int Stock; // Declare Stock Number
};
Sorry for taking awhile. But I don't quite understand, I've got 5 items in my .txt folder, and a for loop that prints those files out in the console with i=0;i<5;i++
If I put the number of records I...
Ok, I'm using a variable called
int loop_value=5;
I've managed to change this to 6,7,8 etc when I add more records by using
loop_value=loop_value+1;
at the end of write to file so that the...
University says void main().
So whether it's right or wrong, i'd be losing marks for int main().
What do you mean, "Fishy?".
It's for a Uni Assignment.
What I am trying to do is return to the main menu (which is under void main()). I have made an If statement asking whether the user wants...
Hey guys, I was wondering what I would do to return to the main function.
Say if I have a switch, and i've gone to switch 1, finished the business in switch 1 but now want to go to switch 3 or...
Just something my assignment requires is all.
I can't seem to manage to transform all my code in to a flowchart, I think it's due to a lack of understanding of what shape means what. Can anybody help with this problem?.
Sorry I haven't replied. I have it sorted now. Thanks for all the help :).
Is there a program that turns pseudocode in to a flowchart?.
Ok thanks, what about when the user has to enter what calculation to do?. There are 4 choices so is that a diamond with 4 arrows leading to other places?.
Hey, I was wondering if anybody could help me with flowchart development.
I have a program that asks the user to enter 5 numbers but i'm unsure what shape in the flowchart that would come under?....
That's perfect, Thanks a lot :D.
____
I've hit a snag by whatever i'm inputting, it's saying it has to be between the 2 values and exits, even if the numbers are between them. Code is:
...
Hey guys i'm wondering how I would end a program prematurely through an if statement if an invalid number is input.
I thought something like this:
int end=0;
...
Ok i've managed to fix it :) Thanks a lot for your help :). I've learnt a lot from just this one problem!.
Thank you for your help :) I have ammended the code as follows:
for (n = 0; n < 5; n++) {
if (max < valc[n])
{ max=valc[n];
printf("Your largest number was:...
#include <stdio.h>
void main()
{
int valc[5]; //valc = Value Count (Amount of Numbers Entered).
int number; //Number for what calculation the user requests.
float average; ...