473,511 Members | 10,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Split a line by whilespace or tabcharacter (\t)

21 New Member
Hi,

I have file in while following line are present

dir1 dir2 dir3 dir2 file1 file2
dir1_file1 dir1_file2\tdir2_file1 dir2_file2\tdir3_file1
...
...

reading a one line at a time from a file,

i'm using the function strtok_r() to split the each line with delimiter whilespace and '\t' character.

How can differentiate that 2 words are split by whitespace or '\t' character.

Is there any work around for this.
Plz let me know.

Thanks.
Sep 16 '11 #1
1 1732
weaknessforcats
9,208 Recognized Expert Moderator Expert
I wouldn't use strtok. Instead examine each character of your search string using isspace. That will detect whitespace and since \t is whitespace, it will be detected by default. Then extract your token using strncpy.
Sep 17 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
2125
by: David Morgenthaler | last post by:
How does one overide the iterator implied by the construct "for line in file:"? For example, suppose I have a file containing row,col pairs on each line, and I wish to write a subclass of file...
2
8039
by: mehul | last post by:
hi all, i am just starting with PERL and had this doubt related to the speical operator +. what it says is that in the line split( / +/,$line); it will not ignore the initial spaces as it starts...
7
17390
by: Alan Silver | last post by:
Hello, I have been having problems with some blindingly simple ASP that fails. I have the following code ... Dim sAds, sAdverts() sAds = "1" & vbTab & "Ferret" & vbTab & "Furry" & vbCrLf...
5
4020
by: NewToThis | last post by:
I am trying to use the split function to bread up lines in a file I am reading from. Some lines are working just fine, but a couple of the lines don't split up the way I would have thought. ...
4
3366
by: dchan1 | last post by:
String line = " I am new to c# "; How to use Regex to split the string so that It would return a String array with: token = "I" token = "am" token = "new" token =...
9
5520
by: acatejr | last post by:
I have a text file and each line is a list of values. The values are not delimited, but every four characters is a value. How do I get python to split this kind of data? Thanks.
2
3739
by: Shawn Minisall | last post by:
I'm trying to unpack a list of 5 floats from a list read from a file and python is telling me 5 variables are too many for the string.split statement. Anyone have any other idea's? NOTE: the only...
11
21149
by: Horacius ReX | last post by:
Hi, I have to search for a string on a big file. Once this string is found, I would need to get the number of the line in which the string is located on the file. Do you know how if this is...
4
1542
by: Gangreen | last post by:
Hi, I'm new to Perl but I have some experience in other languages. Anyway I need to split a string on the character "|". let's say our string is "one|two|three" when I try the following code:...
5
11928
sicarie
by: sicarie | last post by:
I am attempting to parse a CSV, but am not allowed to install the CSV parsing module because of "security reasons" (what a joke), so I'm attempting to use 'split' to break up a comma-delimited file....
0
7251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.