Operating System - Linux
1827856 Members
1499 Online
109969 Solutions
New Discussion

Reading substring from a line

 
SOLVED
Go to solution
Henry Chua
Super Advisor

Reading substring from a line

Hi Guys,

I have create a C program to read a file line by line, but I am interested in knowing how can I read say from character 10 to 20 of a line? Is there a fast way to do this?

Sadly I can only use C...

Best regards
Henry
2 REPLIES 2
H.Merijn Brand (procura
Honored Contributor
Solution

Re: Reading substring from a line


#include
#include
char str2[12];
strcpy (str2, str_org + 10, 10);

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Torsten.
Acclaimed Contributor

Re: Reading substring from a line

Hi Henry,

like inthe answer above, read the whole line in your variable and copy the letters you want to another. What are you planning to do? It may be easier to script it.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!