We help IT Professionals succeed at work.
Get Started

Reading a file - problem with using tokens

jewee
jewee asked
on
384 Views
Last Modified: 2010-04-01
I am reading in a file and am using tokens to parse the data.

Here is one line from the file
fileDir  =  /home/jee

Each line consists of 3 tokens..
I take the first token, and compare it

if(strcmp(first_token, homeDir) == 0)
     strcpy(fileDir, last_token)

I then use that path I extracted from the file to poll that directory.
However, I would get en error when using opendir.  As I stepped through the debugger tool, I noticed that the actual value of the last_token was /home/jee\n
How can I omit the carriage return on that token?

     
Comment
Watch Question
Senior Software Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE