But multiple searches would require 'r+'?
Type: Posts; User: zacharyrs
But multiple searches would require 'r+'?
Ah! that makes perfect sense. Now it works perfectly with the 'r+'.
Weird, but great news: I changed 'a+' to 'r+' and it now works perfect.
Thank you so much for your kind help. Now I'm going to go through and see what I can fix to make it better. If you have...
Thank you. I appreciate your help. However, I have used the search term 'the' and it does not display the number of times it was in there. The count looks like it should be working so I'm not sure...
The problem is you are using code that we haven't been introduced to in class. It would make my prof asking questions, and I wouldn't even understand what I'm learning ;(
Is my code that crappy...
Hmm. Looks like a lot of stuff I haven't learned yet in C :( At this point I'm just trying to get my program to work as it is... I really appreciate your help.
Yeah I need to print - at the bottom of the text file - the mystring and target strings. that is why i was leaning towards the a+ cuz I thought it appended text at the end of the file?
"r" will allow me to "read" and "write" to the file?
At the bottom of the text file, I need to print what they searched for and how many times it showed up. This is why I was using a+. Is this not correct?
Would the issue of not comparing be in this part?
if(strcmp(mystring, target) == 0)
count++;
Ah, the missing #include<string.h> is what was making the string length not work. Thanks for that :)
Also thanks Adak for pointing out the wrong string I'm looking for :) I really appreciate the...
Sorry, I am not exactly sure where I should switch mystring for target regarding your reply.
My goal is to compare the user input (mystring) with the content of the text file (target). If they match then I need to keep a record (using my count variable) and print out how many times the user...
Hmm. Here is what I added:
//compare our strings
do{
//scan through file
fscanf(cfile, "%s", mystring);
//convert string to lowercase
for(i = 0; i < /*strlen(mystring)*/ 300;...
Hi all, I've gotten very close with my project and just need a fresh pair of eyes to point out the obvious. My code seems to parse through the text file, yet does not actually search correctly. My...
Hmm. I think this is a bit more complex than what I'm needing. What about searching a text file for one or two words the user inputs (which would be a string in my case - but generally I'm just...
I am learning the joys of text file manipulation with C and having a blast :) However I am having issues trying to find information online on how to search (specifically a string in my case) in a...
Thank you for your help. Where would proper placement of the break be - outside loop or in the while?
I was able to set a variable and increase it each time to show the number of tries. Yay for me. Anyone know best way of stopping the loop when the user has guessed the number, thus ending the loop...
Would I create an int variable, then increase each time in the loop?
int numGuessed=0;
and later in the loop just do
That way it gets added each time it loops?
That is in place for the loop
//increase the loop until it meets the x variable
i++;
First, thank you for even thinking of helping me. I am a n00b at C and trying to learn every bit I can. I am seeking help so I can understand for future projects, not just an answer :) Also excuse my...
How can I store an actual word with a variable? My ideal would be as thus:
int main ()
{
//introduce variable
whatvariable a;
Ah yes, thank you.
Worked perfectly. What command do I enter to end my program?