chima
asked on
Using append with cin.getline
What syntax does it take to make the
pStringBuf[1].append(str1) work.
error C2228: left of '.append' must have class/struct/union type
Error executing cl.exe.
See below for the code.
These statements don't work as well...why not?
// append the first 2 items from an array of the element type
char achTest[] = {'8', '9', 'A'};
//str1.append(achTest, 2); //works
//achTest[0].append(str1,2 );//does not work
//cout << "str1 = " << str1.c_str() << endl;
// append all of a string literal to str1
char szTest[] = "ABC";
//str1.append(szTest); //works
//szTest.append(str1);//do es not work
#include <string>
#include <iostream>
using namespace std ;
int main()
{
const int stringSize = 10;
const int numOfPhrases =3;
char *pStringBuf[numOfPhrases];
for(int i=0;i<numOfPhrases;i++){
pStringBuf[i]= new char[stringSize];
}
for(i=0;i<numOfPhrases;i++ ){
cin.getline(pStringBuf[i], stringSize ,'\n');
}
cout<< endl << pStringBuf[1] << endl;
string str1("012");
string str2("345");
cout << "str1 = " << str1.c_str() << endl;
// append str2 to str1
str1.append(pStringBuf[1]) ; //This works
pStringBuf[1].append(str1) ; //This does not work.Why not?
cout << "str1 = " << str1.c_str() << endl;
return 0;
}
pStringBuf[1].append(str1)
error C2228: left of '.append' must have class/struct/union type
Error executing cl.exe.
See below for the code.
These statements don't work as well...why not?
// append the first 2 items from an array of the element type
char achTest[] = {'8', '9', 'A'};
//str1.append(achTest, 2); //works
//achTest[0].append(str1,2
//cout << "str1 = " << str1.c_str() << endl;
// append all of a string literal to str1
char szTest[] = "ABC";
//str1.append(szTest); //works
//szTest.append(str1);//do
#include <string>
#include <iostream>
using namespace std ;
int main()
{
const int stringSize = 10;
const int numOfPhrases =3;
char *pStringBuf[numOfPhrases];
for(int i=0;i<numOfPhrases;i++){
pStringBuf[i]= new char[stringSize];
}
for(i=0;i<numOfPhrases;i++
cin.getline(pStringBuf[i],
}
cout<< endl << pStringBuf[1] << endl;
string str1("012");
string str2("345");
cout << "str1 = " << str1.c_str() << endl;
// append str2 to str1
str1.append(pStringBuf[1])
pStringBuf[1].append(str1)
cout << "str1 = " << str1.c_str() << endl;
return 0;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Chase707, I tried your suggestion and I'm getting this error; error C2065: 'vecStringBuf' : undeclared identifier.
Also, I looked in MSDN library, a current C++ Std Library book, and could not fine any information on vecStringBuf.push_back. Where could I find documentation on this?
Also, I looked in MSDN library, a current C++ Std Library book, and could not fine any information on vecStringBuf.push_back. Where could I find documentation on this?
you need to include:
#include <vector>
also, notice the declaration in the example I gave:
vector<string> vecStringBuf;
#include <vector>
also, notice the declaration in the example I gave:
vector<string> vecStringBuf;
The documentation would be for the vector<> container std class.
ASKER
Chase707, I did not have vector<string> vecStringBuf; added. I added it, and now I have error C4786 and it points to the vector header file. Along with one error I have 6 warnings.
I might not be able to get to this problem right away, but being that you are the only one to answer I'll work with you (or please work with ME!).
I might not be able to get to this problem right away, but being that you are the only one to answer I'll work with you (or please work with ME!).
please post the complete text of the error message so I can take a look at it.
most likely the warnings are a quirk of the MS debug build, and will go away with a Release build.
But, post the full text of the error.
most likely the warnings are a quirk of the MS debug build, and will go away with a Release build.
But, post the full text of the error.
ASKER
Chare707,per your request:
Compiling...
DynamicString1.cpp
c:\program files\microsoft visual studio\vc98\include\vector (48) : warning C4786: '??0?$vector@V?$basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@V ?$allocato r@V?$basic _string@DU ?$char_tra its@D@std@ @V?$alloca tor@D@2@@s td@@@2@@st d@@QAE@IAB V
?$basic_string@DU?$char_tr aits@D@std @@V?$alloc ator@D@2@@ 1@ABV?$all ocator@V?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@@ 1@@Z' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (61) : warning C4786: '??0?$vector@V?$basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@V ?$allocato r@V?$basic _string@DU ?$char_tra its@D@std@ @V?$alloca tor@D@2@@s td@@@2@@st d@@QAE@PBV ?
$basic_string@DU?$char_tra its@D@std@ @V?$alloca tor@D@2@@1 @0ABV?$all ocator@V?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@@ 1@@Z' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (103) : warning C4786: '?rbegin@?$vector@V?$basic _string@DU ?$char_tra its@D@std@ @V?$alloca tor@D@2@@s td@@V?$all ocator@V?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@@ 2@@std@@QA
E?AV?$reverse_iterator@PAV ?$basic_st ring@DU?$c har_traits @D@std@@V? $allocator @D@2@@std@ @V12@AAV12 @PAV12@H@2 @XZ' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (105) : warning C4786: '?rbegin@?$vector@V?$basic _string@DU ?$char_tra its@D@std@ @V?$alloca tor@D@2@@s td@@V?$all ocator@V?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@@ 2@@std@@QB
E?AV?$reverse_iterator@PBV ?$basic_st ring@DU?$c har_traits @D@std@@V? $allocator @D@2@@std@ @V12@ABV12 @PBV12@H@2 @XZ' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (107) : warning C4786: '?rend@?$vector@V?$basic_s tring@DU?$ char_trait s@D@std@@V ?$allocato r@D@2@@std @@V?$alloc ator@V?$ba sic_string @DU?$char_ traits@D@s td@@V?$all ocator@D@2 @@std@@@2@ @std@@QAE?
AV?$reverse_iterator@PAV?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@V 12@AAV12@P AV12@H@2@X Z' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (108) : warning C4786: '?rend@?$vector@V?$basic_s tring@DU?$ char_trait s@D@std@@V ?$allocato r@D@2@@std @@V?$alloc ator@V?$ba sic_string @DU?$char_ traits@D@s td@@V?$all ocator@D@2 @@std@@@2@ @std@@QBE?
AV?$reverse_iterator@PBV?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@V 12@ABV12@P BV12@H@2@X Z' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(22) : error C2440: 'type cast' : cannot convert from 'char *[3]' to 'class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<
char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.
DynamicString1.obj - 1 error(s), 6 warning(s)
Compiling...
DynamicString1.cpp
c:\program files\microsoft visual studio\vc98\include\vector
?$basic_string@DU?$char_tr
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
$basic_string@DU?$char_tra
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
E?AV?$reverse_iterator@PAV
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
E?AV?$reverse_iterator@PBV
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
AV?$reverse_iterator@PAV?$
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
AV?$reverse_iterator@PBV?$
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \2\DynamicString1.cpp(22) : error C2440: 'type cast' : cannot convert from 'char *[3]' to 'class std::basic_string<char,str
char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.
DynamicString1.obj - 1 error(s), 6 warning(s)
Please post the code from line 22 so I can take a look at what is causing the error.
Chase707
Chase707
ASKER
Line 22 is
vecStringBuf.push_back(std ::string(p StringBuf) );
I corrected the problem and now I get 10 warnings
Found within this loop, correction shown below:
for(i=0;i<numOfPhrases;i++ ){
cin.getline(pStringBuf[i], stringSize ,'\n');
vecStringBuf.push_back(std ::string(p StringBuf[ i]));}
The first warning points to the VECTOR header file:
vector(const _Myt& _X)
: allocator(_X.allocator)
{_First = allocator.allocate(_X.size (), (void *)0);
_Last = _Ucopy(_X.begin(), _X.end(), _First);
_End = _Last; }
This are the warnings:
compiling...
DynamicString1.cpp
c:\program files\microsoft visual studio\vc98\include\vector (48) : warning C4786: '??0?$vector@V?$basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@V ?$allocato r@V?$basic _string@DU ?$char_tra its@D@std@ @V?$alloca tor@D@2@@s td@@@2@@st d@@QAE@IAB V
?$basic_string@DU?$char_tr aits@D@std @@V?$alloc ator@D@2@@ 1@ABV?$all ocator@V?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@@ 1@@Z' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (61) : warning C4786: '??0?$vector@V?$basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@V ?$allocato r@V?$basic _string@DU ?$char_tra its@D@std@ @V?$alloca tor@D@2@@s td@@@2@@st d@@QAE@PBV ?
$basic_string@DU?$char_tra its@D@std@ @V?$alloca tor@D@2@@1 @0ABV?$all ocator@V?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@@ 1@@Z' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (103) : warning C4786: '?rbegin@?$vector@V?$basic _string@DU ?$char_tra its@D@std@ @V?$alloca tor@D@2@@s td@@V?$all ocator@V?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@@ 2@@std@@QA
E?AV?$reverse_iterator@PAV ?$basic_st ring@DU?$c har_traits @D@std@@V? $allocator @D@2@@std@ @V12@AAV12 @PAV12@H@2 @XZ' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (105) : warning C4786: '?rbegin@?$vector@V?$basic _string@DU ?$char_tra its@D@std@ @V?$alloca tor@D@2@@s td@@V?$all ocator@V?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@@ 2@@std@@QB
E?AV?$reverse_iterator@PBV ?$basic_st ring@DU?$c har_traits @D@std@@V? $allocator @D@2@@std@ @V12@ABV12 @PBV12@H@2 @XZ' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (107) : warning C4786: '?rend@?$vector@V?$basic_s tring@DU?$ char_trait s@D@std@@V ?$allocato r@D@2@@std @@V?$alloc ator@V?$ba sic_string @DU?$char_ traits@D@s td@@V?$all ocator@D@2 @@std@@@2@ @std@@QAE?
AV?$reverse_iterator@PAV?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@V 12@AAV12@P AV12@H@2@X Z' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
c:\program files\microsoft visual studio\vc98\include\vector (108) : warning C4786: '?rend@?$vector@V?$basic_s tring@DU?$ char_trait s@D@std@@V ?$allocato r@D@2@@std @@V?$alloc ator@V?$ba sic_string @DU?$char_ traits@D@s td@@V?$all ocator@D@2 @@std@@@2@ @std@@QBE?
AV?$reverse_iterator@PBV?$ basic_stri ng@DU?$cha r_traits@D @std@@V?$a llocator@D @2@@std@@V 12@ABV12@P BV12@H@2@X Z' : identifier was truncated to '255' characters in the browser information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::alloca
tor<char> >,class std::allocator<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> > > >' being compiled
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(74) : warning C4786: 'std::reverse_iterator<std ::basic_st ring<char, std::char_ traits<cha r>,std::al locator<ch ar> > const *,std::basic_string<char,s td::
char_traits<char>,std::all ocator<cha r> >,std::basic_string<char,s td::char_t raits<char >,std::all ocator<cha r> > const &,std::basic_string<char,s td::char_t raits<char >,std::all ocator<cha r> > const *,int>' : identifier was truncated to '255' characters i
n the debug information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(74) : warning C4786: 'std::reverse_iterator<std ::basic_st ring<char, std::char_ traits<cha r>,std::al locator<ch ar> > *,std::basic_string<char,s td::char_t
raits<char>,std::allocator <char> >,std::basic_string<char,s td::char_t raits<char >,std::all ocator<cha r> > &,std::basic_string<char,s td::char_t raits<char >,std::all ocator<cha r> > *,int>' : identifier was truncated to '255' characters in the debug inform
ation
c:\program files\microsoft visual studio\vc98\include\vector (39) : warning C4786: 'std::vector<std::basic_st ring<char, std::char_ traits<cha r>,std::al locator<ch ar> >,std::allocator<std::basi c_string<c har,std::c har_traits <char>,std ::allocato r<char> > >
>::vector<std::basic_strin g<char,std ::char_tra its<char>, std::alloc ator<char> >,std::allocator<std::basi c_string<c har,std::c har_traits <char>,std ::allocato r<char> > > >' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\vector (60) : warning C4786: 'std::vector<std::basic_st ring<char, std::char_ traits<cha r>,std::al locator<ch ar> >,std::allocator<std::basi c_string<c har,std::c har_traits <char>,std ::allocato r<char> > >
>::~vector<std::basic_stri ng<char,st d::char_tr aits<char> ,std::allo cator<char > >,std::allocator<std::basi c_string<c har,std::c har_traits <char>,std ::allocato r<char> > > >' : identifier was truncated to '255' characters in the debug information
DynamicString1.obj - 0 error(s), 10 warning(s)
vecStringBuf.push_back(std
I corrected the problem and now I get 10 warnings
Found within this loop, correction shown below:
for(i=0;i<numOfPhrases;i++
cin.getline(pStringBuf[i],
vecStringBuf.push_back(std
The first warning points to the VECTOR header file:
vector(const _Myt& _X)
: allocator(_X.allocator)
{_First = allocator.allocate(_X.size
_Last = _Ucopy(_X.begin(), _X.end(), _First);
_End = _Last; }
This are the warnings:
compiling...
DynamicString1.cpp
c:\program files\microsoft visual studio\vc98\include\vector
?$basic_string@DU?$char_tr
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
$basic_string@DU?$char_tra
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
E?AV?$reverse_iterator@PAV
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
E?AV?$reverse_iterator@PBV
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
AV?$reverse_iterator@PAV?$
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
c:\program files\microsoft visual studio\vc98\include\vector
AV?$reverse_iterator@PBV?$
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(11) : see reference to class template instantiation 'std::vector<class std::basic_string<char,str
tor<char> >,class std::allocator<class std::basic_string<char,str
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(74) : warning C4786: 'std::reverse_iterator<std
char_traits<char>,std::all
n the debug information
C:\Program Files\Microsoft Visual Studio\MyProjects\C++ \DynamicString1.cpp(74) : warning C4786: 'std::reverse_iterator<std
raits<char>,std::allocator
ation
c:\program files\microsoft visual studio\vc98\include\vector
>::vector<std::basic_strin
c:\program files\microsoft visual studio\vc98\include\vector
>::~vector<std::basic_stri
DynamicString1.obj - 0 error(s), 10 warning(s)
ASKER
Bumped points.
Those warnings are part of combining the MS debug library with the Standard Template Library and can be ignored. You will not get these warnings in the release build.
If you want to disable the warning, put the following line after your stdafx.h include, if you have one, and before your <string>, <iostream> and other STL includes
#pragma warning(disable:4786)
If you want to disable the warning, put the following line after your stdafx.h include, if you have one, and before your <string>, <iostream> and other STL includes
#pragma warning(disable:4786)
Dear Chima,
Referring to your initial program:
append () is a method of string, and so, it can only be accessed with objects of class string. Since 'pStringBuf' has bene defined as char **, so it won;t be able to access that method ever. However, you can change it to
string pStringBuf[numOfPhrases] ;
Or if you want to continue with your initial code, just write:
strcat ( pStringBuf[1], str1 ) ;
Hope that helps!
Mayank.
Referring to your initial program:
append () is a method of string, and so, it can only be accessed with objects of class string. Since 'pStringBuf' has bene defined as char **, so it won;t be able to access that method ever. However, you can change it to
string pStringBuf[numOfPhrases] ;
Or if you want to continue with your initial code, just write:
strcat ( pStringBuf[1], str1 ) ;
Hope that helps!
Mayank.
ASKER
Chase707, sorry for the absence, had a death in the family. Just getting back. Thanks for your comments and help. Please keep in touch for other questions I may have.
Mayank, thanks for your comments. The use of char** as described by Chase707 worked very well. I realize that it was an awkward way of dealing with the string, but I needed to fulfill the requirement to use a function named append, concat, etc., for the program.
Mayank, thanks for your comments. The use of char** as described by Chase707 worked very well. I realize that it was an awkward way of dealing with the string, but I needed to fulfill the requirement to use a function named append, concat, etc., for the program.
ASKER
A++, once again thanks
ASKER