I'm just wondering if anyone know an efficient algorithm to remove an object from an array and move everything up.
ie removing 2 from 1, 2, 3, 4, 5
will be 1, 3, 4, 5
Do I need to use pointers?
Type: Posts; User: SIKCAR
I'm just wondering if anyone know an efficient algorithm to remove an object from an array and move everything up.
ie removing 2 from 1, 2, 3, 4, 5
will be 1, 3, 4, 5
Do I need to use pointers?
sorry, I missed a ) when I typed it here, but that wasn't the problem
basically I get
parse error before 'const'
in an example I've got, they were comparing char
but they could do
...
what do you mean by non inline function?
thanks
now when I want to use the function in my main function
I get parse error
I tried to do mysort(keyArray, 50, 30, compare(const void *,const void *);
and mysort is
void mysort(int...
so in this case, inside maindriver.c
in the main function
can I still use the functions from function.c? when I have only included function.h?
eg
#include<stdio.h>
#include "function.h"
int...
Oh just thought you would also want to know how to print out the backslash (\) character too
you just do \\
and \' to print out '
\" to print out "
\? to print out ?
int compare( const void *op1, const void *op2 )
{
const char **p1 = (const char **) op1;
const char **p2 = (const char **) op2;
return( strcmp( *p1, *p2 ) );
}
When I tried...
When compiling one of my function, it gives me a warning message
"passing arg 4 of 'qsort' from incompatible pointer type"
what does this mean?
here's some of the codes that's related
int...
alright thanks :)
And just a bug in the program, with the very same code.
I somehow take in the last element of my input file in twice, and printing them out twice in my for loop.
ie it prints
456 aaa
124 abc
124...
Oh, I forgot to include string.h
thanks for that ;)
I'll keep trying to use fputs and fprintf to store the data.
I guess I could also try opening the dictionaryfile up, coz I'm meant to pick random words out of the dictionaryfile which has over 20000...
also, I'm not too familiar at using strdup
can you please explain how to free the memory malloc()'d by this function?
Thanks,
Will
Thanks for that, I have also checked for the return values.
But now I have error compiling the line
array[i].name = strdup (name);
"warning: assignment makes pointer from integer without a...
I think the subject of this thread is probably wrong. But basically I've written a program to print out exactly what I wanted to stdout, but having trouble writing to a file.
The codes I have...
Hi I'm trying to store some words from an input file to an array, but I keep getting segmentation faults.
The input text file looks something like this
135 hello
124 help
1 first
each word...