Hi every one,
I am a newbie in C++ and have some experience in C.
My program always seems like a mixture of C and C++,
especially when dealing with string. sometimes I use
std::string but I have some difficult on controlling it
for example:
// format the string as what I like
sprintf(s, "%s%d",buf,i )
I don't know how to do it in std::string in C++
1. Any suggestion about what kind of material I should read
online or book will both be good.
another problem is when I use string under gcc 2.9.*
sometimes met compile error like
<char> ......(I don't remember clearly, but no such problem in
the newest gcc compiler)
so,
2. what about the different gcc version's support of c++ standard ? 4 1127
"Lingyun Yang" <yz***@insightbb.com> wrote in message
news:CeKdc.3021$rg5.28995@attbi_s52... Hi every one,
I am a newbie in C++ and have some experience in C. My program always seems like a mixture of C and C++, especially when dealing with string. sometimes I use std::string but I have some difficult on controlling it for example: // format the string as what I like sprintf(s, "%s%d",buf,i )
I don't know how to do it in std::string in C++
One way is
ostringstream tmp;
tmp << buf << i;
string s = tmp.str();
Another way is to look at the format library from boost (www.boost.org)
which lets you do printf like formatting on strings. 1. Any suggestion about what kind of material I should read online or book will both be good.
Depends on what you know already. I reckon Scott Meyers books Effective C++
and More Effective C++ might be good for you. another problem is when I use string under gcc 2.9.* sometimes met compile error like <char> ......(I don't remember clearly, but no such problem in the newest gcc compiler)
so,
2. what about the different gcc version's support of c++ standard ?
2.9 is not so good. 3.x is much better.
john
"Lingyun Yang" <yz***@insightbb.com> wrote in message
news:CeKdc.3021$rg5.28995@attbi_s52... Hi every one,
I am a newbie in C++ and have some experience in C. My program always seems like a mixture of C and C++, especially when dealing with string. sometimes I use std::string but I have some difficult on controlling it for example: // format the string as what I like sprintf(s, "%s%d",buf,i )
I don't know how to do it in std::string in C++
One way is
ostringstream tmp;
tmp << buf << i;
string s = tmp.str();
Another way is to look at the format library from boost (www.boost.org)
which lets you do printf like formatting on strings. 1. Any suggestion about what kind of material I should read online or book will both be good.
Depends on what you know already. I reckon Scott Meyers books Effective C++
and More Effective C++ might be good for you. another problem is when I use string under gcc 2.9.* sometimes met compile error like <char> ......(I don't remember clearly, but no such problem in the newest gcc compiler)
so,
2. what about the different gcc version's support of c++ standard ?
2.9 is not so good. 3.x is much better.
john
Lingyun Yang <yz***@insightbb.com> wrote: I am a newbie in C++ and have some experience in C. My program always seems like a mixture of C and C++, especially when dealing with string. sometimes I use std::string but I have some difficult on controlling it for example: // format the string as what I like sprintf(s, "%s%d",buf,i )
I don't know how to do it in std::string in C++
1. Any suggestion about what kind of material I should read online or book will both be good.
Accelerated C++ would probably be a good choice for you.
Lingyun Yang <yz***@insightbb.com> wrote: I am a newbie in C++ and have some experience in C. My program always seems like a mixture of C and C++, especially when dealing with string. sometimes I use std::string but I have some difficult on controlling it for example: // format the string as what I like sprintf(s, "%s%d",buf,i )
I don't know how to do it in std::string in C++
1. Any suggestion about what kind of material I should read online or book will both be good.
Accelerated C++ would probably be a good choice for you. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lingyun Yang |
last post by:
Hi every one,
I am a newbie in C++ and have some experience in C.
My program always seems like a mixture of C and C++,
especially when dealing with string. sometimes I use
std::string but I...
|
by: Michele Simionato |
last post by:
This is somewhat in between a bug report and a feature request.
I was using the new string.Template class and I have run into a
few issues that I traced back to the usage of the idiom
'%s' % val...
|
by: Joe H |
last post by:
Hi i converted a program to a lib. The parameters of main are
maincommand(int argc, char **argv)
I want to use main a s function that takes a string how can i convert
a char * to a char ** or even...
|
by: John Leslie |
last post by:
I need to write a string to a file in EBCDIC.
Do I need to do it character by character using a translation table,
or is there a function to translate the whole string?
(I am aware that I can...
|
by: Felix Kater |
last post by:
The C-faq says that "The malloc/free implementation remembers the size
of each block allocated and returned, so it is not necessary to remind
it of the size when freeing."
Could that length...
|
by: francescomoi |
last post by:
Hi.
I'm trying to remove some characters within a string and substitute
others. For instance, I want to convert:
John's new house, great ---> Johns-new-house-great
I tried with:...
|
by: Jami Bradley |
last post by:
Hi,
I'm looking for an efficient way to do this, because I know it will be heavily used :-)
I have a fixed width string and I need to substitute a substring of characters with new values. I...
|
by: yaru22 |
last post by:
Hi, I'm relatively new to C programming and was quite confused by this
error.
What I tried to do is that if I have a string with double quotes
around it (i.e. char *str = "\"hello\"";), I have...
|
by: Mo |
last post by:
Hi,
I am trying to write a code to build a string 768 characters long.
This string is going to be written to a file which is then read by
another application. The format of the string is already...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |