Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ Vectory not playing with Strings

Status
Not open for further replies.

woodshop2300

Technical User
Oct 6, 2005
3
US
Code:
#include <string.h>
#include <iostream>
#include <vector>

using namespace std;

int main()
	{
	vector<string> strlist(70);
	return 0;
	}
throws 4 warnings
Code:
C:\Program Files\Microsoft Visual Studio\MyProjects\HW_Program_3_Hashing\HW_Program_3_Hashing.cpp(15) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::ch
ar_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255' characters in 
the debug information
C:\Program Files\Microsoft Visual Studio\MyProjects\HW_Program_3_Hashing\HW_Program_3_Hashing.cpp(15) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_tra
its<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug informat
ion
c:\program files\microsoft visual studio\vc98\include\vector(47) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >
 >::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<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_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >
 >::~vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
Linking...
not sure why it don't work. I can see no reasion for it to not.
 
You can safely ignore those warnings, they are common with VC++ 6.0 STL code. It just means that the identifiers are truncated in the debug data.

To get rid of the warning, put at the top of the file:
Code:
#pragma warning(disable: 4786)
You can also put that inside the STL files that give the error (like vector in this case) to get rid of the annoyance more permanently.

By the way, your string header should be <string>, not <string.h>. Those are two different things. The <string> header is for the C++ string class that you are using. The <string.h> header is for C style string helper functions like strcpy, and in C++ is deprecated in favor of <cstring>. Your code works because on your compiler <iostream> includes some of the declarations used by string, but you'll want to fix it before continuing with the code.
 
Thanks on the String.h part that should save me some trouble when i get into this more.

That killed the warnings thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top