I want to replace the following line:
sscanf(mybuf,"%s=%s\n",sz1,sz2);
with something that produces the same effect, only with
dynamic storage i.e string s which is safer.
I might try this:
sscanf(mybuf.c_str(),"%s=%s\n",string1.c_str(),str ing2.c_str());
but unsuprisingly this causes an error at runtime since there is nothing to
stop a memory overrun happening.Additionally there is no compile time check
as sscanf uses varargs.
Can anyone recommend the quickest way of acheiving this, short of writing
my own parser.
Mark 1 6189
Mark wrote: I want to replace the following line:
sscanf(mybuf,"%s=%s\n",sz1,sz2);
with something that produces the same effect, only with dynamic storage i.e string s which is safer.
I might try this:
sscanf(mybuf.c_str(),"%s=%s\n",string1.c_str(),str ing2.c_str());
but unsuprisingly this causes an error at runtime since there is nothing to stop a memory overrun happening.Additionally there is no compile time check as sscanf uses varargs.
Can anyone recommend the quickest way of acheiving this, short of writing my own parser.
Something similar to
string::size_type eq = mybuf.find('=');
string string1 = mybuf.substr(0, eq), string2 = mybuf.substr(eq+1);
V This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Martin Jørgensen |
last post by:
Hi,
- - - - - - - - - - - - - - -
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
|
by: ehui928 |
last post by:
hi, everybody
I am a newbie in STL. When I compile the following program under
gcc4.0, I got a the following errors.
I wonder whether the form of list< vector<string> > is correct in STL
?
//...
|
by: buzzweetman |
last post by:
Many times I have a Dictionary<string, SomeTypeand need to get the
list of keys out of it as a List<string>, to pass to a another method
that expects a List<string>.
I often do the following:
...
|
by: arnuld |
last post by:
This works fine, I welcome any views/advices/coding-practices :)
/* C++ Primer - 4/e
*
* Exercise 8.9
* STATEMENT:
* write a program to store each line from a file into a
*...
|
by: Carmen Sei |
last post by:
it seem to me that when doing include -
#include <string.h- is CRT
#inlcude <string- is C++ standard library
Is that true those header with .h extension is CRT and those without
extension...
|
by: parez |
last post by:
Hi,
I am trying to serialize List<List<string>.
With the following code
public List<List<string>DataRows { get; set; }
|
by: Mr. K.V.B.L. |
last post by:
I want to start a map with keys but an empty vector<string>. Not sure
what the syntax is here.
Something like:
map<string, vector<string MapVector;
MapVector.insert(make_pair("string1",...
|
by: barcaroller |
last post by:
In the boost::program_options tutorial, the author included the following
code:
cout << "Input files are: "
<< vm.as< vector<string()
<< "\n";
Basically, he is trying to print a vector...
|
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: 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: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
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: 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...
| | |