Thread: from .txt to database

  1. #1
    Registered User
    Join Date
    Mar 2019
    Posts
    2

    from .txt to database

    I have a .txt file (the content are from one data type say it is numerical) and I want to open this file using C then read its content and then put its content in MySQL database is this possible and how?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,078
    Yes. You would use say, fopen, fscanf (or fread, if it was written with fwrite rather than text), and fclose to read the content of the text file, then the MySQL C API to store the value to the database.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Mar 2019
    Posts
    2
    Quote Originally Posted by laserlight View Post
    Yes. You would use say, fopen, fscanf (or fread, if it was written with fwrite rather than text), and fclose to read the content of the text file, then the MySQL C API to store the value to the database.
    actually I'm beginner in programming and don't know what is API, could you help me, provide an exaple or any site
    tnnx

  4. #4
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,859
    Fact - Beethoven wrote his first symphony in C

  5. #5
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    663
    Quote Originally Posted by myp1lteandroid View Post
    actually I'm beginner in programming and don't know what is API, could you help me, provide an exaple or any site
    tnnx
    "...I'm beginner in programming..."

    You need a thorough understanding of the C Programming language BEFORE you attempt to add any API, or Application Programming Interface to a project, especially the MYSQL API..

    Take a course in C, with a qualified instructor, or study a good book on C. There is a link here to some C book recommendations, but the list is a little out of date, and needs to be updated.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Database to Database Transfer?
    By draggy in forum C++ Programming
    Replies: 4
    Last Post: 01-17-2007, 10:50 AM
  2. Database without OS.....
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 12-28-2003, 01:25 PM
  3. which database do u use ??
    By moemen ahmed in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 08-27-2003, 11:12 AM
  4. Database
    By JHOOMAN in forum C Programming
    Replies: 1
    Last Post: 04-02-2002, 09:59 AM
  5. Replies: 1
    Last Post: 10-09-2001, 10:20 PM

Tags for this Thread