![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
Searching a file
I need to search a file for a specific number. or instance this is what the file
contains: 1001234592 and i want the program to search the file for '4' could anyone help me? |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
What have you tried so far? It is really easy. You read the file, character by character, You compare each character using this line of code:
if(c - '0' == 4) |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
thats part of my problem i can't figue out how to read it character by character
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
getchar() getc() ?
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
thank you nnxion.
nice your an Expert Programmer |
|
|
|
|
|
#6 | |
|
Programmer
|
Quote:
![]() |
|
|
|
|
|
|
#7 |
|
Expert Programmer
|
Riddle, he meant that nnxion is an "Expert Programmer" because he has over 500 posts, so it updated his title.
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#8 |
|
Hobbyist Programmer
|
lol yea
|
|
|
|
|
|
#9 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
|
#10 |
|
Hobbyist Programmer
|
Perhaps you should try it
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|