Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4586056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:35:06+00:00 2026-05-21T21:35:06+00:00

I have an requirement where the C code extract string data from database and

  • 0

I have an requirement where the C code extract string data from database and write it to a file. The string data in the database can have any kind of characters

for example: Description field have data “Adj \342\200\223 Data” , when I write to the file the text it writes as “Adj â Data”. Similarly, this description field can have any kind of data, my code just read and uses strcpy after extracting from the database and write to a file.

How do I get the data written to a file as it is in the description field ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:35:07+00:00Added an answer on May 21, 2026 at 9:35 pm

    Think easiest solution would be writing byte by byte – shouldn’t matter that much with buffering:

    int pos = 0;
    FILE *fp = 0;
    //...
    fp = fopen("somefile.txt", "w");
    //...
    while(buffer[pos])
        if(buffer[pos] < 32 || buffer[pos] > 127) // change bounds for non-printable chars as you like
            fprintf(fp, "%c", buffer[pos++]);
        else
            fprintf(fp, "\\%u", buffer[pos++]);
    

    Edit:
    Might have misunderstood your question. Only use string functions when you’re actually working with strings. For binary data use binary functions (e.g. the mentioned memcpy()).

    Edit 2/3:
    Don’t print the value as “%d” or “%u” – should be “%3o” to print as a 3-digit octal number. Using “%o” could be unsafe if other digits follow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement to extract a distinct subset of rows from a DataTable,
I have a requirement to make a large amount of code MISRA compliant. First
Normally I create web application projects and use code-behind, but I have a requirement
We have the requirement to take a form submission and save some data, then
I have a requirement in my application that I think can be met by
I have the requirement to access the following data, where available, on mobile phones
I have a requirement to update the properties file based upon the input provided
I have a requirement where users should be able to navigate from the first
I have a requirement to use VB6 generated dlls in .Net code but I
I have a requirement to execute a perl script from a PL/SQL script. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.