Thanks for trying it. Works OK on my laptop so I'll just have to run the prog on that from now on. It's been a strange and futile affair really, like I alluded to in previous posts I have a few progs...
Type: Posts; User: Matt13
Thanks for trying it. Works OK on my laptop so I'll just have to run the prog on that from now on. It's been a strange and futile affair really, like I alluded to in previous posts I have a few progs...
Tried code on another computer and everything worked fine. I compiled using gcc 3.3 just as before but everything worked fine. Why did this happen?
the not-so-magic header file
Program works for values of N up to 16 and bums out from 18 onwards... It also works for (seemingly) all values of N if I make fprintf go to stdout instead of fptr. It's rather frustrating...
I...
Thankyou. I was aware of the size issue and I forgot to include an int number_of_games thingie.
Thanks again :)
(PS: I broke #1 rule of the board and didn't check elsewhere before posting -...
I want to know if you can have a struct with a component that is a pointer to an array of indeterminate length? Say something like:
struct log {
int registration_number;
int *scores;
}
OK yes I may have been misguided in not putting up code. I really can't find the problem even with gdb (although a man with a chisel is not necessarily a sculptor) and I'm getting nowhere...
This...
Sorry I was trying to get down to the heart of the problem - my code has diagnostic statements all over it and would probably stretch the thread this way and that where it is too wide in places....
Please scroll down to my last post!!
I am compiling sucessfully using gcc 3.3 but on running my program seg faults. I have isolated the problem as being to do with an fprintf line which is fine if...
Thankyou Prelude.
Hello,
I would like to read in a file of the form:
1 2 1
1 3 1
1 4 1
....
2 1 1
2 4 1
The thing is, I want to delete only "deleteme" and keep the rest of the array intact, but less that one element. It seems like such a simple thing to do... yet it's driving me nuts!
I've tried to...
void update(int deleteme, int array[], int size)
{
int i,j=0;
int *temp;
temp=array;
while(array[j]!=deleteme)
j++;
array=realloc(array,sizeof(int)*(size-1));
...
*coughs nervously* I might be...
... if I were, what should I do instead?
(Also , if I used that old line "it seems to work" - what would be a sign that it actually wasn't?)
Matt
Thanks. When I came to code the problem that had provoked the question, I actually found it wasn't an issue.
None of the online man pages say what happens when you realloc down to a smaller sized...
When using realloc to resize an array of say six ints to one of five ints, is it the sixth int "array[5]" that gets junked or is there no protocol?
Matt
Hmmm! A schoolboy error! Now to fix that error in the deletethings subfunction! :)
Sorry!
OK. There are at least two errors in the attached code (the associated .h file has a few in too I am sure). I get the second when I eliminate most of the references to the array "nodes" which seems...
... always use google!
http://www.eskimo.com/~scs/cclass/int/sx9b.html (in case anyone else is interested!)
Thanks. I have implemented this but the compiler seems to be having more fun with the declaration of trays generally.
This is definitely my problem area of C. Can anyone point me to a decent tutorial/faq on this? I can't seem to find one on this site but I may well be wrong!
My problem is essentially this:
I...
I think the problem lies within the for loop that I've attached the comment "\\pref attach m nodes" to. I get the feeling that because the 0th case is dealt with seperately, the 2nd case...
This is a program that seeks to represent a network following the Barabasi-Albert algorithm. We start with a randomly generated cluster for an initial n nodes (user input) and then to each of the...
Thankyou.
A simple idea but so effective. :) I should be able to make everything work from here.