I have a problem. I have a function that search a string in a text file. This function return an int: 0 if the string I must be search isn't in the file, 1 otherwise.
The problem is: if the searching string is "input1" and in the file there is a string "counter_input1" the function return 1 instead must be return 0.
Bye
:idea: :idea: :idea:
ricciola
0
Newbie Poster
Recommended Answers
Jump to PostPost your code plz....
Jump to Postwhen the string is found, check the character immediately before and after to see if it is a space. If not a space, then the string is not what you want.
Jump to PostWell, in that case it would be nice to post your solution...
Jump to Postuse fgets() instead of fgetc() and your program will work better and be a lot less complicated.
delete line 5, NULL is defined in standard c header files.
remove the braces on lines 11, 12 and 13. They are not necessary there.
All 15 Replies
SpS
34
Posting Pro
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
ricciola
0
Newbie Poster
Micko
2
Junior Poster
ricciola
0
Newbie Poster
rajuss
-1
Newbie Poster
Salem
commented:
Me too Me too - I want to bump a dead thread :( :( :*
-1
Aia
1,977
Nearly a Posting Maven
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
rajuss
-1
Newbie Poster

iamthwee
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
akshay1
0
Newbie Poster
Adak
419
Nearly a Posting Virtuoso
shellk007
-3
Newbie Poster
WaltP
commented:
To do what, exactly? Show people a bad way to program? If so, then yes, this is one way to write bad (and dangerous) code.
-3
shentong
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.