Help please.. I need some help in C to open a file and search for a string. If the string is found then move one space and copy the next string to end-of-line back to buffer. I am creating a program using pthreads and need to search this file in a thread. Just a simple code if possible would help. Thanks.
jeffhorton1965 5 Newbie Poster
Recommended Answers
Jump to PostWhat two things are wrong with this line
scanf("%d", &abc[30]);
???hint for 1: you have defined abc as a character array, didn't you?
You need to study the
printf()
function closer...
Jump to PostI have changed a few things around. Still not completely working.
Maybe you're using the wrong logic.
If you want to ask a question, ask a detailed question and you'll get help.
If you want us to say "Awww, poor program :'(" post a statement like you did …
Jump to PostDid you remove the trailing '\n' from your input string using
fgets()
? It's always good to examine the data read to see if there are anomalies in your console input. There usually are...strstr()
is used to search a string. It looks like you simply needstrcmp()
.
All 12 Replies
jephthah 1,888 Posting Maven
jeffhorton1965 5 Newbie Poster
jephthah 1,888 Posting Maven
jeffhorton1965 5 Newbie Poster
jeffhorton1965 5 Newbie Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
jeffhorton1965 5 Newbie Poster
jeffhorton1965 5 Newbie Poster
WaltP commented: Was there a need to quote your other post? -2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
jeffhorton1965 5 Newbie Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
jeffhorton1965 5 Newbie Poster
jephthah commented: you're welcome +7
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.