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 6717531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:51:49+00:00 2026-05-26T08:51:49+00:00

This is a very small portion of a large project… These are typedefs defined

  • 0

This is a very small portion of a large project…

These are typedefs defined in standard header file for the project.

typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;
typedef uint8_t  u_int8_t;

Now this is the actual function causing problem …

void function(u_int8_t *data1, u_int32_t data1len,
    u_int8_t *data2, u_int32_t data2len)
{

FILE *fq,*fr,*fs;
    char *data3;
    int data3len;

    data3len=data1len+data2len;

    printf("\n%d",data1len);
    printf("\n%d",data2len);
    printf("\n%d",data3len);

fq=fopen("data1.txt","wb");
fwrite((char *)data1,data1len,1,fq);

fr=fopen("data2.txt","wb");
fwrite((char *)data2,data2len,1,fr);

data3=(char *)data1;
strcat(data3,(char *)data2);

fs=fopen("data3.txt","wb");
fwrite((char *)data3,data3len,1,fs);

}

Some output Snapshots …

40
14
54


 udit@udit-Dabba ~$ hexdump -C data1.txt
 00000000  60 00 00 00 00 8c 06 00  00 00 00 00 00 00 00 00  |`...............|
 00000010  00 00 00 00 00 00 00 01  00 00 00 00 00 00 00 00  |................|
 00000020  00 00 00 00 00 00 00 02                           |........|
 00000028

 udit@udit-Dabba ~$ hexdump -C data2.txt
 00000000  00 26 00 26 00 00 00 01  00 00 00 02 34 12 00 65  |.&.&........4..e|
 00000010  00 34 00 00 61 62 63 64                           |.4..abcd|
 00000018

 udit@udit-Dabba ~$ hexdump -C data3.txt
 00000000  60 00 00 00 00 8c 06 00  00 00 00 00 00 00 00 00  |`...............|
 00000010  00 00 00 00 00 00 00 01  00 00 00 00 00 00 00 00  |................|
 00000020  00 00 00 00 00 00 00 02  00 78 f8 65 00 00 00 02  |.........x.e....|
 00000030  f4 1f 96 00 18 34 a6 bf  1c 03 96 00 88 f1 90 08  |.....4..........|
 00000040

Why contents of data2.txt are not copied to data3.txt ??? If there is any other possible way then please tell me !!!! Thanx in advance …

  • 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-26T08:51:49+00:00Added an answer on May 26, 2026 at 8:51 am

    I think you could do it much easier, saving you from ensuring that the respective memory block is large enough.

    void function(u_int8_t *data1, u_int32_t data1len,
        u_int8_t *data2, u_int32_t data2len)
    {
        FILE *fq,*fr,*fs;
        char *data3;
    
        fq=fopen("data1.txt","wb");
        fwrite((char *)data1, data1len, 1, fq);
        fclose(fq);
    
        fr=fopen("data2.txt","wb");
        fwrite((char *)data2, data2len, 1, fr);
        fclose(fr);
    
        fs=fopen("data3.txt","wb");
        fwrite((char *)data1, data1len, 1, fs);
        fwrite((char *)data2, data2len, 1, fs);
        fclose(fs);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large web application. One very small piece of this web application
So I am obviously not a very good programmer. I have written this small
I've written this very simple function to replace a file extension using LINQ in
This is a very small question, and probably something really silly! But why am
This is very strange. I am using SVG images, because of the low file
I'm having trouble getting a short MP3 file to play in a very small
I'm loading this (very small) image using: UIImage* image = [UIImage named:@someFile.png]; The image
I have just read this [very nice] small tutorial about MYSQL error handling. I
Consider this very small contrived subset of my schema: SensorType1 ID : PK SensorType2
This very simple code gives me tons of errors: #include <iostream> #include <string> int

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.