We help IT Professionals succeed at work.

Searching + Deleting from databases in C?

ryb2001
ryb2001 asked
on
Medium Priority
200 Views
Last Modified: 2010-04-15
Hi,

I want to search a database/text file/master record by Surname, Post-code and/or Email Address, and also delete and entry from a master file yet i do not know how.

I know how to print ALL of the selected fields in a master file, yet not search, for example...


------------

               printf ("Address    : %s\n", contacts[i].address1);
                  printf ("             %s\n", contacts[i].address2);
                  printf ("             %s\n", contacts[i].address3);
                  printf ("PostCode   : %s\n", contacts[i].postcode);
                  printf ("Home Number: %s\n", contacts[i].homenumber);
                  printf ("Mob. Number: %s\n", contacts[i].mobnumber);
                  printf ("Email      : %s\n", contacts[i].email);

-------------

Any help/examples are appreciated

Ryan
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
U can use fwrite() to write the entire structure i.e. one record in one statement rather than having to write one field at a time.


Hello Ryan,

If you are comfortable in DB programming using C on windows then you can also try the ODBC route.
Even for text files there are Text drivers available where once you connect and open a datasource
it is very trivial to perform queries and searches.

The effort for writing parsing and searching logics would be less but then it has its own challenges.

Visit
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetmicrosoft_desktop_database_drivers.asp

Enjoy
Anup
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.