When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
44 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
buf in your case is a pointer to 1 byte of memory (sizeof(char) is guaranteed to be always 1).
If SIZE is any bigger than 1 the code might SEGFAULT.
both char buf[SIZE] and char *buf = malloc(SIZE) work
like initially yea its NULL, but why is it saying invalid read? if its accessing a NULL ptr shouldn;t it return NULL
Go through the code imagining the start parameter is NULL
Also what is arr?
Also you're not ensuring that arr[strlen(buf) - 5] doesn't access a negative index
that’s why I tried creating a temp node with dummy attributes when I create my linkedlist and making that the head so that the linked list isn’t null when it gets created
no difference
so like if we assume it’s not null when it gets created, even if I have the checks for null
LL start shouldn’t be null right? Can the invalid read/write come from anywhere else or is it most likely because the linked list is null
Share the full error message please
is it ok if i send it in like an hour ish? I just left the house
Just send it when you can. The error shouldn't change over the next hour
Could you just send the whole code? You're feeding me snippets the entire time and I really don't feel like pulling everything out of your nose
Like everything that is relevant in order for the error to occur.
If the error is in insert then why do you send me only create_linked_list?
sporry i thought it would be easier for u to reference the insert func when i sent it earlier
is it ok if i send the code in a private dm?
no
ok
do you have an idea of where the invalid read is coming from?
line 40
You're somehow passing NULL to insert
but tbh, I have no real clue. Why don't you just debug it to see how you're trying to access NULL?
like print stuff? or another way
gdb
debugger
You must've debugged before
It's essential to programming in any language
i pretty much only use valgrind and printing stuff to debug
heard of gdb just never used it
get familiar with it
Nowadays I spent almost half of my time programming in the debugger
Only debugger that sucked so far was Haskell's
because of lazy evaluation
But C's is kind of nice once you got used to it
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.