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.
Ok.. Still not working. I am trying to create this so I can convert it to a function in a pthread. I have all other aspects of my main program running but can get this to run correctly. What is suppose to happen is when is receives the information, it looks in a file and finds the information. Then it returns the next information. I am creating a client/server program for dns lookup. My dnsfile looks like: www.abc.com10.100.100.1 www.123.edu10.101.101.1
(and so on)..
I need to get it to see the url and return the ip address. Code is below:
char *strstr(const char *abc, const char *tur);
i = 0;
f = fopen("dnsfile", "r");
printf("Finding IP Address for URL: \n");
if ( f != NULL)
while (fgets(tur, 29, f) != NULL)
if (strstr(abc, tur) != 0)
fgets(tur, 30, f);
printf("Your IP Address is: %s", tur);
Sorry about not posting the right question but not an everyday programmer here..
What I can't get to work is comparing the "abc" string to the "tur" string. I have tried the "strcmp" and "strstr" which should return a 0 if matching or found. I use the "printf" just to see what is in "abc" and "tur".. Any suggestions on comparing two strings...
Did 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 need strcmp() .
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...