I just started to learn C, so I hope you don't mind that I will post here the newbie-problems I do run into. I am learning C as a hobby, just as I learned Basic, Pascal and VB(A) in the past. So now I want to learn the "famous C" :P.
Well, here we go....
You can use "strncpy' to copy a number of characters from one string to another. That is handy, but what I really would like is that I can copy a number of characters from a given position in the source string to the destination string. I tried some things....
Having in mind that a string in C is an array of char, I tried this:
strncpy(dest_str, source_str, 10)
I hoped that strncpy would start at position 4 of the source string and copied 10 characters. But when I compiled the program, the compiler told me that it hated me and stopped :P.
Then I thought that maybe a pointer could help me. So I tried the next something
But after that I got an casting error.
strcpy(regel1, "Programing is fun and relaxing to do");
ptr = ®el1;
strncpy(regel2, *ptr, 3);
Okay, so how to solve this problem... can I use "strncpy" at all to get done what I want? I mean, something like that would be nice for other functions as "memset" too.
Thank you already for your answering and advices.
(BTW the name Joke is no joke . It is very common Dutch girls name and is pronounced as "jo-ke" and not as the English word joke).