• 0 Posts
  • 5 Comments
Joined 6 months ago
cake
Cake day: March 1st, 2026

help-circle

  • the strtok issue is, per the man page, that strtok returns only “non empty” tokens with your given delimiters.

    Given only one delimiter, the strchr approach is likely what I’d use. understanding strchr (and the similar strstr) is a pretty useful thing to have anyway, so it’s a good time to learn it. strchr makes no modifications and isn’t aiming to make tokens for you. It is looking for the first instance of a given byte in a C string and, provided it found it, returning you a pointer to that byte. as such, if it returns you something other than NULL, you’ve got a pointer to a byte. assuming you’re fine with the function modifying the buffer, you can convert that byte to a nul byte (\0), then print buffer, then a new line. You then advance your buffer pointer to the byte past the now-nul byte. Continue until strchr returns NULL, which is your last line - assuming the buffer is nul-terminated

    Edit: example, now that I’ve got a real keyboard:

    void strchr_loop(char *buf) {
        char* p;
        while ((p = strchr(buf, '\n')) != NULL) {
            *p = '\0';
            printf("Line = %s\n", buf);
            buf = p + 1;
        }
        printf("Last line = %s\n", buf);
    }
    


  • My ISP charges a good chunk for static IP (because they consider it a business connection). However, my $10/mo VPS (which I already had for other projects) has its own static IP and I can easily proxy individual requests through it as needed. Have looked at VPS instances for $5/months before.

    Depending on the service, your ISP, and how easily you can change IPs in the registration, as others have mentioned, you could just give them your public. I’ll say my own public does change at least twice a month, so if I can’t automate updating a registration, it goes through VPS or it’s a service I just skip.