Thank you :) It's a big help
Type: Posts; User: lucaspewkas
Thank you :) It's a big help
ummm, well I'm willing to wait, but I'll work it out myself if you don't want to, was just trying to save a bit of time...
But wouldn't that convert the entire string after that element? I need it to stop at header[8]. And also how do you point to an element within an array? Because if I just put header[4] as the...
OK so I have a char* variable, which contains the header for a particular packet. There are various fields in this packet but the header isn't split up into different variables. So my question is,...
cool thanks, that worked :)
OK once again, pointers are causing me headaches
I'm trying to get a word from a file, and write that into a buffer. The buffer is malloced like so:
char *buf = malloc( INIT * sizeof(char) );...
yeah, it was all wrong, I need it to be a FILE* anyway...:)
Thanks thats all I wanted to do, then I just malloced inside the function. Haven't used global variables much, didn't think about trying to store a non-constant value :)
I'm trying to define a char* global variable (is this bad practice?) but keep getting an error message "initializer element is not constant"
the code is as follows:
char* inputfile = malloc(...
Yeah that's what I thought, but when I run it through gdb, if I put a string longer than MAXBUF in, it WILL get cut-off automatically, but the next time the while loop comes around, instead of...
Yep, pretty easy to guess I suppose, damn sorting project took me ages. Still, I learned a hell of a lot from it so it's not all bad.
OK I know I've posted something like this before but I now have a slightly different problem.
I am reading in input to a buffer line by line (using fgets) and then putting the buffer into an array...
Don't worry, I worked everything out, yay!
For anyone that was interested, instead of doing:
child = 2*parent + width
I just did:
Thanks, that cleared up some things, but I still cannot find the child nodes. The children appear at 2*parent+1 in a heap as far as I know, but when parent is void* (or unsigned char*) rather than...
I am trying to write a heap sort function using the prototype:
void
heap_sort(void *base, size_t nel, size_t width, int(*compar)(const void *, const void *));
where base is a pointer to...
Thanks guys, it's all working. Guess it isn't really that hard if you think about it :)
Is there a function that will, if a string has more that 100 chars in it, just cut off anything after the 100th char?
If not, any hints on how to start writing this function myself?
Thanks
Thankyou so much, you have no idea how much this was @%*#ing me :)
It all works now, guess I need to learn a bit more about malloc and pointers, maybe another day...
I am having trouble writing input from stdin to an array of strings in C. Forgive me if this is trivial but I really hate dealing with strings, they seem easy but never work for me. Here is some...