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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:56:21+00:00 2026-05-27T05:56:21+00:00

I am concatenating several strings. When running the program it gives me a Debug

  • 0

I am concatenating several strings. When running the program it gives me a Debug Assertion Failed! message which says Expression: (L”String is not null terminated” && 0).

All strings seem to be NULL terminated, but I am not sure what else could it be. Any ideas?

I am including the code excerpt where it triggers the problem.

void foo(){
    ....
    char adj_command_string[COMMAND_SIZE];
    reconstructCommand(&command_parameters, adj_command_string);
    ....
}


void reconstructCommand(command* command_data, char* adjusted_string){

    char partial_string[COMMAND_SIZE];
    char string_rep[COMMAND_SIZE];

    if (command_data->g_code.new_value){
        sprintf_s(string_rep, COMMAND_SIZE, "G%d ", command_data->g_code.value);
        strcat_s(partial_string, COMMAND_SIZE, string_rep);
    }

    // If position changed, include change in command.
    if (command_data->pos.X.value){
        sprintf_s(string_rep, COMMAND_SIZE, "X%.4f ", command_data->pos.X.value);
        strcat_s(partial_string, COMMAND_SIZE, string_rep);
    }

    if (command_data->pos.Y.value){
        sprintf_s(string_rep, COMMAND_SIZE, "Y%.4f ", command_data->pos.Y.value);
        strcat_s(partial_string, COMMAND_SIZE, string_rep);
    }

    if (command_data->pos.Z.value){
        sprintf_s(string_rep, COMMAND_SIZE, "Z%.4f ", command_data->pos.Z.value);
        strcat_s(partial_string, COMMAND_SIZE, string_rep);
    }

    if (command_data->pos.A.value){
        sprintf_s(string_rep, COMMAND_SIZE, "A%.4f ", command_data->pos.A.value);
        strcat_s(partial_string, COMMAND_SIZE, string_rep);
    }

    // If Feedrate originally included, include it in modified command
    if (command_data->feedrate.new_value){
        sprintf_s(string_rep, COMMAND_SIZE, "F%.4f ", command_data->feedrate.value);
        strcat_s(partial_string, COMMAND_SIZE, string_rep);
    }

    // If spindle speed originally included, include it in modified command
    if (command_data->speed.new_value){
        sprintf_s(string_rep, COMMAND_SIZE, "S%.4f ", command_data->speed.value);
        strcat_s(partial_string, COMMAND_SIZE, string_rep);
    }

    adjusted_string = partial_string;
}
  • 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-27T05:56:22+00:00Added an answer on May 27, 2026 at 5:56 am

    I am not sure if this is the source of the problem but:

    adjusted_string = partial_string;
    

    Will not copy the contents of partial_string into adjusted_string. Use strcpy() or some other similar mechanism and ensure that adjusted_string is null terminated.

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

Sidebar

Related Questions

Guys I'm generating a string which rappresent a path to a file, concatenating a
Say you have several large arrays of variables (which generally are strings), and you
Since performance of string concatenation is quite weak in VB6 I'm testing several StringBuilder
I am looking for a more elegant way of concatenating strings in Ruby. I
I know you should use a StringBuilder when concatenating strings but I was just
I'm writing a PHP script that builds an SQL query by concatenating the string
Before moving to PDO, I created SQL queries in PHP by concatenating strings. If
I have a Python function accepting several string arguments def foo(a, b, c): and
I'd like to create a PHP image generator that takes several query string parameters
Possible Duplicate: Why is String.Concat not optimized to StringBuilder.Append? One day I was ranting

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.