473,388 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

String manipulation question

22
I need to concatenate a string with a dynamic part (don't know what the %d's and it's likes are called)... And exactly the fact that I don't know the name of what I'm trying to do is what makes so hard to google it :)

What I wan't to look something like this in my head:

Expand|Select|Wrap|Line Numbers
  1. strcat(ret, "! [%d] %s", i, buf);
  2.  
The code above won't work, but what will? I don't wan't to do a dozen of strcats either...

I hope somebody will point it out :)

Thanks in advance
Nov 17 '08 #1
3 1302
arnaudk
424 256MB
You're not looking for sprintf(), are you?
Nov 17 '08 #2
JosAH
11,448 Expert 8TB
To augment on the previous reply: sprintf() to the end of the buffer:

Expand|Select|Wrap|Line Numbers
  1. sprintf(ret+strlen(ret), "your format string here", a, b, c, d);
  2.  
kind regards,

Jos
Nov 17 '08 #3
krreks
22
Hi.

The sprintf function was what I was looking for, I found it myself and the problem got solved :)

Thanks anyway!
Nov 17 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: CoolPint | last post by:
Is there any way I can reduce the size of internal buffer to store characters by std::string? After having used a string object to store large strings, the object seems to retain the large...
9
by: Rune | last post by:
Is it best to use double quotes and let PHP expand variables inside strings, or is it faster to do the string manipulation yourself manually? Which is quicker? 1) $insert = 'To Be';...
16
by: zohaibbaloch | last post by:
how to manipulate string without using arrays.manipulation example i have to print dog or any string i want to cut d from dog and paste it a end and add a at the last dog becoms ogda. please...
4
by: Dim | last post by:
I found that C# has some buggy ways to process string across methods. I have a class with on global string var and a method where i add / remove from this string Consider it a buffer... with some...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
7
by: John A Grandy | last post by:
what are the preferred VB.NET analogues for IsNumeric() and Len() and CInt() & similar string-manipulation functions in VB6
4
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if...
4
by: yumyu | last post by:
Hi, If i have a Title called " John Smith" and if i press a command button, it changes to "Smith nhoJ" How do i do that with loop and string manipulation? Thanks
14
by: Newbie Coder | last post by:
Hi all, VB.NET 2003 ONLY PLEASE I have a registry key (HKCU\Software\Newbie\SomeKey) of type string which holds an XML string as follows: <root formID="preferencesform" lang="english" ...
13
by: Logan Lee | last post by:
Hi. I've written a small program to learn to write in C. But unfortunately the output is all jumbled up and not nice. /* read_file.c The whole point of this code is to read the entire content...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.