Thank u
Type: Posts; User: wiqxlzxsxj
Thank u
I want to look at the problem of tokenizing a string. Calling strtok() changes the original string by placing '\0' in lieu of the tokens. I was wondering if there was a trick to avoid this. I want to...
The printf family of functions work perfectly in my example and are legible to read. They are "the standard" way to implement io/manipulate strings.
I'm looking for a more direct way to just print...
No .
Yes this is what I want.
What is fwrite() doing? It's outputting the contents at &f in its binary form to stdout. Seems I need another operation to do the actual conversion to a type float. My bad...
Now it gets worse....
I was looking to not use printf family of functions.
Curious though why doesn't fwrite() work in this example? This is what a few tutorials show how to use fwrite().
I have this little program. It outputs the binary conversion to the console (aka garbled output). Is there a way to fwrite() numerical types to the output?
#include int main()
{
float...
The correct term is "Flexible array member" for the data field in the struct. Feature introduced in C99.
Yes that is what I was trying to do. Thanks!
Though I also managed to work it out using two mallocs for the list and then calling realloc on list->data alone.
List *list = malloc(sizeof...
Well, just realized that the static size_t vars in the struct are anchoring the struct down from dynamic reallocation. The allocation occurs but then it overflows its neighbors as a result thus...
If I add elements to the block before that realloc, memcpy works fine.
I'm trying to implement a dynamic array using a struct:
typedef struct
{
size_t count, el_size, alloc_count;
void *data;
} List;
The problem was clearly outlined in the first post.
qsort() sorts array, arrays of structs, but it won't sort "anything". For example lists. Instead of trying to fudge this problem I implemented my...
With all due respect I am not your apprentice. If you consider yourself to be in a teaching position then all you've done is to suggest workarounds to the original problem. This isn't an exercise to...
How is this at all related to the original question? You could work around to fit in qsort(). But that isn't the priority here!
There is plenty of evidence of retardation in this thread already.
qsort is part of the C std. lib.
It doesn't use malloc(). It uses a similar type approach I described above.
I would prefer to reuse a pre-existing library if I could. But I am not using qsort...
For an embedded application (or for any application for that matter) you have to make predetermined assumptions about variable sizes. For example fixed char sizes to store strings etc, which my...
Point is, I want to leave scratch as arbitrary storage variable instead of assuming to cast it as data from the outset.
I have a struct of doubles like so:
struct data
{
double x;
double y;
double z;
} data;
OK that's a fair enough explanation I was looking for. In terms of the assembly instructions, an int will always be an int.
I am asking if printf will segfault? But by atomic I am referring to atomicity of a given operation in each mutually exclusive thread. So if X is being changed in the other thread and at the same,...
I have already debugged the problem and the problem lies somewhere in the ncurses (wprintw) implementation that I have done. Basically there are variables being updated in another thread and the...
I was interested to know if there is any process already in place to check variables when printing them using printf or wprintw.
Here is the scenario. There are variables being changed and altered...