Conversation
why do it segfault? hmm
3
0
0
@kirby you're dereferencing a null pointer
1
0
1
@pwm yeah but the problem is where exactly am i dereferencing it, it's not obvious hsre
2
0
0
@kirby doublecheck your usage of strtok and strdup would be the frst places I'd look. There are subtleties to strtok iirc, since it mangles the thing you give it
1
0
1
@pwm yeah that's what I'm gonna have to do when i get my hands on a debugger on the Book catSleep
1
0
0
@kirby Don't quote me but I think it replaces the first character of the delimiter (it supports multiple iirc) with nulls, breaking the string into an array. I don't think that would make your free call fail as it has no way to muck about with the value of the pointer, so I think the culprit is inside your loop somehow, perhaps atoi?
1
0
0
@pwm that would be a, really weird issue but I'll see if that's the case later
1
0
0

@kirby I got it to compile by flipping the strtok in the last for loop argument

  for (char *c = strtok(str, "."); c != NULL; c = strtok(NULL, str)) {

it prints junk though

./kirby 127.0.0.1
1111111..
1
0
1
@stacksmash oh that's my bad LMAO

anyways the logic is probably flawed idk nothing i ever write works the first time when it comes to trying to replicate human instructions into code
0
0
0
@pwm fucked up the arguments in the latter call, it is supposed to be strtok(NULL, ".");
3
0
1
@kirby I think strtok does some internal housekeeping so that does sorta make sense.
1
0
1
@kirby
This looks like pajeet code, what are you even trying to do?
1
0
1
@dj convert decimal octets in ip to binary lmao
0
0
1