I have char *initialurl = "http://example.demo.com:80/demo/path"
expecting output:
char *protocol = "https://"
char *url = "example.demo.com"
char *port = "80"
char *path = "/demo/path"
I tried
char *initialurl = "http://example.demo.com:80/demo/path"
char *port = strstr(initialurl, ":");
if(port) {
port = strtok(port, "/") + 1;
printf("PORT: %s\n", port);
}
Similarly, I am trying to use same char *initialurl to split. By then, memory value of variable changing to "http://example.demo.com".
How can i get path?? Do I need to copy char *initialurl to new variable?
Please suggest. Thank you