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

  • Home
  • SEARCH
  • 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 6347657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:15:42+00:00 2026-05-24T21:15:42+00:00

I have a program which concatenates some number of strings in a buffer. I

  • 0

I have a program which concatenates some number of strings in a buffer.

I was using strncpy before. After looking into some suggetions on web to use snprintf instead of strncat, I switched to snprintf. However, I have noticed a delay in execution of this part of program(string concatenation) then before. Is this possible, that snprintf can slow down the program exucution speed? If not then I will look for some other factors in my program.

if(iOffset<MAX_BUFF_SIZE && iOffset>0)
{
  ....... 
  iOffset += snprintf(cBuff+iOffset, sizeof(cBuff)-iOffset, "%s", "String1");
  ...... 
}

I repeat the above code snippet like 12 times in order to append strings to cBuff.

Edit : It repeats 12 times after each 1 sec.

  • 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-24T21:15:43+00:00Added an answer on May 24, 2026 at 9:15 pm

    There are a couple of suggestions that come to mind:

    • don’t optimize your program too early
    • when you’re ready to optimize, use a tool like a profiler to discover where the real slow downs are

    If you’re not familiar with profiling, or are really eager to know the timing details you can always include timers around your code. See references on gettimeofday() or clock() and the appropriate caveats about those codes. Essentially you can get the time before execution, the time after and compare them. Comment out your line of code and put in the old code and time it.

    With all that said … that’s part of what a profiler does for you. Figuring out “why” something is slow is sometimes complex because there may be other considerations going on (ie at the hardware level) that you’re not aware of.

    The execution of a function 12 times is probably trivial compared to the total execution time of the program.

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

Sidebar

Related Questions

I have a program which works with strings (Pascal). After reading a string if
I have program which loads an assembly using Asssembly.LoadFrom method. Some time later I
I have a program which has some Textareas / Labels these can be anywhere
I have a program which draws some terrain and simulates water flowing over it
I have a program which write logging as Text File. namespace logging { using
I have a program which accepts 2 N -digit numbers, multiplies them using threads
I have a program which transmits(broadcasts) and receives UDP packets simultaneously using pthreads. What
I have program which reads MSMQ using GetAllMessages but it does not remove messages
I have a program which uses an io_service and several threads. It instantiates some
I have a program which creates a timer using timerfd_create (the timer when it

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.