LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 11-08-2006, 11:03 PM   #16
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 673

Original Poster
Rep: Reputation: 57

Alright, I took your advice and took out my clears.
I saw what you ment when I looked at other command line programs
and you were right. I don't know why I wanted them in there in the first
place.

Two things.

That loop above works very well for filtering out letters from the input.
Only problem is I don't understand it. Any chance you can explain to me
why it works?

Second, I am at a lost. I'm trying to make it so when you give the program
a path, it counts the files in the directory to see how many there are.
I can't find out how to do this with c++. Can someone help me with that
please.

I appreciate everyone's help and I'm learning a lot this is great.

Thanks,

nomb
 
Old 11-09-2006, 08:35 AM   #17
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
i have used ftw() to traverse a dir structure. you could use it to count, im sure there is probably a better idea though.

the loop only accepts valid input because it uses the cin extraction operator. the extract op knows that you are extracting into an int, so it only accepts an int. if it fails, the clear() call resets the stream error flags so that you can try again.
 
Old 11-10-2006, 03:40 AM   #18
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 673

Original Poster
Rep: Reputation: 57
I see that makes sense. I can't find ftw(). Also I can't find any way to list the files. Well actually, I just want to count the files but if I can figure out how to list them I can count them. I found something called boost but I have no idea how to use it. :'( Can anyone help me?

nomb
 
  


Reply

Tags
c++, md5


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 09:04 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration