Hello,
I am using visual c++ 6 and i am having problems with string to work.
******** Here is the program project.cpp*********
#include <iostream.h>
#include <string>
#include "stdafx.h"
// This program just inverts the tickers.csv files execpt first line
int main(){
string ticker ;
return 0;
}
***************************
on compiling i get this error message
**************************
Compiling...
StdAfx.cpp
Compiling...
Project.cpp
C:\Windows\Desktop\Project\Project.cpp(17) : error C2065: 'string' :
undeclared identifier
C:\Windows\Desktop\Project\Project.cpp(17) : error C2146: syntax error
: missing ';' before identifier 'ticker'
C:\Windows\Desktop\Project\Project.cpp(17) : error C2065: 'ticker' :
undeclared identifier
Error executing cl.exe.
Project.exe - 3 error(s), 0 warning(s)
****************************
can someone tell me whats wrong here ?
thank you in advance.
Gaurav 6 10760
Gaurav wrote: #include <iostream.h>
Drop the .h!
#include <iostream>
#include <string>
string ticker ;
std::string ticker;
--
WW aka Attila
"Gaurav" <ba********@hotmail.com> wrote in message
news:42*************************@posting.google.co m... Hello,
I am using visual c++ 6 and i am having problems with string to work.
******** Here is the program project.cpp*********
#include <iostream.h>
No such header in standard C++. The header which
declares the standard streams is <iostream> (no .h)
You're not using anything from it anyway, so you
can simply omit this line.
#include <string>
#include "stdafx.h"
A Microsoft specific header, not part of standard C++.
The code you've posted doesn't need it anyway, so
you can omit this line.
// This program just inverts the tickers.csv files execpt first line
Looks to me like all it does (tries to do) is define a string
object, then terminate.
int main(){
string ticker ;
std::string ticker; return 0; }
Applying changes I point out, we get:
#include <string>
int main()
{
std::string ticker;
return 0;
}
which will successfully compile without a diagnostic
on a compliant implementation, as well as with VC++ v6.0
***************************
on compiling i get this error message ************************** Compiling... StdAfx.cpp Compiling... Project.cpp C:\Windows\Desktop\Project\Project.cpp(17) : error C2065: 'string' : undeclared identifier
Accurate diagnostic message.
C:\Windows\Desktop\Project\Project.cpp(17) : error C2146: syntax error : missing ';' before identifier 'ticker'
An artifact of the first message.
C:\Windows\Desktop\Project\Project.cpp(17) : error C2065: 'ticker' : undeclared identifier
An artifact of the first message.
Error executing cl.exe.
Yup. :-) Project.exe - 3 error(s), 0 warning(s) ****************************
can someone tell me whats wrong here ?
See above.
-Mike
"Mike Wahler" <mk******@mkwahler.net> wrote in message news:<KK*****************@newsread4.news.pas.earth link.net>... "Gaurav" <ba********@hotmail.com> wrote in message news:42*************************@posting.google.co m... Hello,
I am using visual c++ 6 and i am having problems with string to work.
******** Here is the program project.cpp********* #include <iostream.h>
No such header in standard C++. The header which declares the standard streams is <iostream> (no .h) You're not using anything from it anyway, so you can simply omit this line.
#include <string>
#include "stdafx.h"
A Microsoft specific header, not part of standard C++. The code you've posted doesn't need it anyway, so you can omit this line.
// This program just inverts the tickers.csv files execpt first line
Looks to me like all it does (tries to do) is define a string object, then terminate.
int main(){
string ticker ;
std::string ticker;
return 0; }
Applying changes I point out, we get:
#include <string>
int main() { std::string ticker; return 0; }
which will successfully compile without a diagnostic on a compliant implementation, as well as with VC++ v6.0
***************************
on compiling i get this error message ************************** Compiling... StdAfx.cpp Compiling... Project.cpp C:\Windows\Desktop\Project\Project.cpp(17) : error C2065: 'string' : undeclared identifier
Accurate diagnostic message.
C:\Windows\Desktop\Project\Project.cpp(17) : error C2146: syntax error : missing ';' before identifier 'ticker'
An artifact of the first message.
C:\Windows\Desktop\Project\Project.cpp(17) : error C2065: 'ticker' : undeclared identifier
An artifact of the first message.
Error executing cl.exe.
Yup. :-)
Project.exe - 3 error(s), 0 warning(s) ****************************
can someone tell me whats wrong here ?
See above.
-Mike
********************
thanx
It works fine now. i have another problem using vector<string>
#include "stdafx.h"
#include <fstream>
//#include <ofstream.h>
#include <string>
#include <vector>
using namespace std;
// This program just inverts the tickers.csv files execpt first line
int main(){
//string ticker, line;
//string input,output;
//ifstream Tickers( "tickers.txt", ios::in);
//ifstream Input_File;
//ofstream Output_File;
vector<string> temp;
/*
while(Tickers>>ticker){
input = "tempdata/" + ticker + ".csv";
output = "tempdata/" + ticker + "1.csv";
Input_File.open( input.c_str(), ios::in);
Output_File.open ( output.c_str(), ios::app);
while ( Input_File >> line ){
temp.push_back(line);
}
Output_File << temp[0] << endl;
for ( unsigned i = ( temp.size() - 1 ); i > 0; i--)
Output_File << temp[i] << endl;
temp.clear();
Input_File.close();
Output_File.close();
}
*/
return 0;
}
Here effectively i just have vector<string> temp in main, everything
else is commented.
If i compile this program i get following warnings
*********************
Compiling...
project.cpp
C:\Windows\Desktop\project\project.cpp(43) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std: :char_traits<char>,std::allocator<char> const *,std::basic_string<char,std::char_traits<char>,st d::allocator<char> ,std::basic_string<ch
ar,std::char_traits<char>,std::allocator<char> > const
&,std::basic_string<char,std::char_traits<char>,st d::allocator<char> >
const *,int>' : identifier was truncated to '255' characters in the
debug information
C:\Windows\Desktop\project\project.cpp(43) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std: :char_traits<char>,std::allocator<char> *,std::basic_string<char,std::char_traits<char>,st d::allocator<char> ,std::basic_string<char,std
::char_traits<char>,std::allocator<char> >
&,std::basic_string<char,std::char_traits<char>,st d::allocator<char> >
*,int>' : identifier was truncated to '255' characters in the debug
information
c:\program files\microsoft visual studio\vc98\include\vector(39) :
warning C4786: 'std::vector<std::basic_string<char,std::char_trai ts<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_trai ts<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...
project.exe - 0 error(s), 4 warning(s)
***********************
how can i get rid of these ?
Also if i remove all the comments, i have problems with temp.clear()
All this program is doing is inverting about 40 files, whose names are
in tickers.txt.
thank you in advance.
Gaurav
in the top of the codes
u can do it as following, bcoz not namespace:):
....
#include <string>
....
using namespace std;
void fun()
{
std::string str;
}
"Gaurav" <ba********@hotmail.com> wrote in message
news:42*************************@posting.google.co m... Hello,
I am using visual c++ 6 and i am having problems with string to work.
******** Here is the program project.cpp********* #include <iostream.h> #include <string>
#include "stdafx.h"
// This program just inverts the tickers.csv files execpt first line int main(){
string ticker ;
return 0; } ***************************
on compiling i get this error message ************************** Compiling... StdAfx.cpp Compiling... Project.cpp C:\Windows\Desktop\Project\Project.cpp(17) : error C2065: 'string' : undeclared identifier C:\Windows\Desktop\Project\Project.cpp(17) : error C2146: syntax error : missing ';' before identifier 'ticker' C:\Windows\Desktop\Project\Project.cpp(17) : error C2065: 'ticker' : undeclared identifier Error executing cl.exe.
Project.exe - 3 error(s), 0 warning(s) ****************************
can someone tell me whats wrong here ?
thank you in advance.
Gaurav
"Gaurav" <ba********@hotmail.com> wrote in message
news:42*************************@posting.google.co m... It works fine now. i have another problem using vector<string> #include "stdafx.h" #include <fstream> //#include <ofstream.h> #include <string> #include <vector>
using namespace std;
// This program just inverts the tickers.csv files execpt first line int main(){
//string ticker, line; //string input,output; //ifstream Tickers( "tickers.txt", ios::in); //ifstream Input_File; //ofstream Output_File; vector<string> temp; /* while(Tickers>>ticker){ input = "tempdata/" + ticker + ".csv"; output = "tempdata/" + ticker + "1.csv"; Input_File.open( input.c_str(), ios::in); Output_File.open ( output.c_str(), ios::app); while ( Input_File >> line ){ temp.push_back(line); } Output_File << temp[0] << endl; for ( unsigned i = ( temp.size() - 1 ); i > 0; i--) Output_File << temp[i] << endl; temp.clear(); Input_File.close(); Output_File.close();
} */
return 0; }
Here effectively i just have vector<string> temp in main, everything else is commented.
If i compile this program i get following warnings
********************* Compiling... project.cpp C:\Windows\Desktop\project\project.cpp(43) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std: :char_traits<char>,std::al
locator<char> const
*,std::basic_string<char,std::char_traits<char>,st d::allocator<char>,std::basic_string<ch ar,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,st d::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information C:\Windows\Desktop\project\project.cpp(43) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std: :char_traits<char>,std::al
locator<char> *,std::basic_string<char,std::char_traits<char>,st d::allocator<char> ,std::basic_string<char,std ::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,st d::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information c:\program files\microsoft visual studio\vc98\include\vector(39) : warning C4786:
'std::vector<std::basic_string<char,std::char_trai ts<char>,std::allocator<ch
ar> ,std::allocator<std::basic_string<char,std::char_ traits<char>,std::allocato
r<char> ::vector<std::basic_string<char,std::char_traits< char>,std::allocator<char>
,std::allocator<std::basic_string<char,std::char_ 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_string<char,std::char_trai ts<char>,std::allocator<ch
ar> ,std::allocator<std::basic_string<char,std::char_ traits<char>,std::allocato
r<char> ::~vector<std::basic_string<char,std::char_traits <char>,std::allocator<char
,std::allocator<std::basic_string<char,std::char_ traits<char>,std::allocato
r<char> >' : identifier was truncated to '255' characters in the debug information Linking...
project.exe - 0 error(s), 4 warning(s) ***********************
how can i get rid of these ?
These can be safely ignored. If you want to hide them look in the MS
documentation for the #pragma method to do this. #pragma is not part of
standard C++, so any detailed questions about this should be directed to a
MS specific newsgroup.
Also if i remove all the comments, i have problems with temp.clear()
What problems exactly.
> If i compile this program i get following warnings ********************* Compiling... project.cpp C:\Windows\Desktop\project\project.cpp(43) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std: :char_traits<char>,std::allocator<char> const *,std::basic_string<char,std::char_traits<char>,st d::allocator<char> ,std::basic_string<ch ar,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,st d::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information C:\Windows\Desktop\project\project.cpp(43) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std: :char_traits<char>,std::allocator<char> *,std::basic_string<char,std::char_traits<char>,st d::allocator<char> ,std::basic_string<char,std ::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,st d::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information
[...snip...]
how can i get rid of these ?
Also if i remove all the comments, i have problems with temp.clear()
All this program is doing is inverting about 40 files, whose names are in tickers.txt.
thank you in advance.
Gaurav
This is a problem with VC. You need to include
#pragma warning(disable: 4786)
at the top of the relevant header files. If there are many then do it in stdafx.h
Cheers,
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Epson Barnett |
last post by:
I'm working on learning .NET and I'm curious about the reason for
using static methods in some cases. Specifically, the string class has
a split and a join method, but only the join method is...
|
by: Steve |
last post by:
Hi Guys,
I have a string which contains data elements separated by spaces. I also
have a function which returns the number of characters from the beginning of
the string for a given number of...
|
by: Peter Jansson |
last post by:
Hello,
I have the following code:
std::map<int,std::set<std::string> > k;
k="1234567890";
k="2345678901";
//...
std::set<std::string> myMethod(std::map<int,std::set<std::string> > k)...
|
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...
|
by: Matt |
last post by:
string format formula to write a text file
below is not working for me
pos 1 to 10 name
pos 15 to 30 lastname
pos 45 to 75 job
Adam smith programmer
string fmt = "{1,10}{15-30}{45,75}"...
|
by: rsine |
last post by:
I have developed a program that sends a command through the serial port
to our business system and then reads from the buffer looking for a
number. Everything worked great on my WinXP system, but...
|
by: April |
last post by:
Hope someone can help me
The SQL string i need to use does not work, Who can help me....
Thanks in advance
Dim strConn As String
Dim strSQL As String
|
by: SeNTry |
last post by:
Hi Everyone,
My first post here as I just begin to learn programming in general and
python in particular. I have all the noobie confused questions, but as I
work thru the tutorials I'm sure...
|
by: SQACSharp |
last post by:
How can I "convert" from a char to a string. I'm trying to display in
the console the Classname and the text in the notepad window.
Start notepad and type some text before running the following...
|
by: coconet |
last post by:
I have a string like this
mystring = "color1:blue;color2:red";
I am tring to convert this into an IDictionary populated like this:
color1 blue
color2 red
My non-working syntax is
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |