Negat1ve Posted January 1, 2010 Share Posted January 1, 2010 Well i have little improved my skills in C++ but i need help =\ Is there any way to convert String to int ? Or just read line from file as int Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 1, 2010 Share Posted January 1, 2010 This is in the wrong category, but conversion probably isn't neccesary. See Language Reference - Datatypes - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Negat1ve Posted January 1, 2010 Author Share Posted January 1, 2010 This is for autoit .. i need to know how to do it in C++ ( MS Visual C++ 2008 ) Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 1, 2010 Share Posted January 1, 2010 (edited) Oh sorry. I didn't read correctly. I can't help you either, I'm not familiar with c++, but maybe Google can.. string int conversion c++ - Google Search Edited January 1, 2010 by snowmaker - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
monoceres Posted January 1, 2010 Share Posted January 1, 2010 (edited) It's all about streams.#include <iostream> #include <sstream> #include <fstream> using namespace std; int main() { // Converting using stringstream stringstream ss("123"); int num; ss>>num; cout << num << endl; // Getting line as int directly fstream file("somefile.txt",ios::in); int num2; file >> num2; cout << num2 << endl; }Edit: Beautiful, isn't it? Edited January 1, 2010 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Negat1ve Posted January 1, 2010 Author Share Posted January 1, 2010 heh never used std functions =D but i will try it and let you know if it works =) Link to comment Share on other sites More sharing options...
Negat1ve Posted January 1, 2010 Author Share Posted January 1, 2010 Doesnt work =\ Output : ------ Build started: Project: DropCalcDropImport, Configuration: Release Win32 ------ Compiling... DropCalcDropImport.cpp d:\project\dropcalcdropimport\dropcalcdropimport\Form1.h(191) : error C2039: 'ss' : is not a member of 'std' d:\project\dropcalcdropimport\dropcalcdropimport\Form1.h(192) : error C2065: 'endl' : undeclared identifier d:\project\dropcalcdropimport\dropcalcdropimport\Form1.h(195) : error C2653: 'ios' : is not a class or namespace name d:\project\dropcalcdropimport\dropcalcdropimport\Form1.h(195) : error C2065: 'in' : undeclared identifier d:\project\dropcalcdropimport\dropcalcdropimport\Form1.h(195) : error C2079: 'file' uses undefined class 'std::basic_fstream<_Elem,_Traits>' with [ _Elem=char, _Traits=std::char_traits<char> ] d:\project\dropcalcdropimport\dropcalcdropimport\Form1.h(195) : error C2078: too many initializers d:\project\dropcalcdropimport\dropcalcdropimport\Form1.h(197) : error C2039: 'file' : is not a member of 'std' d:\project\dropcalcdropimport\dropcalcdropimport\Form1.h(197) : warning C4552: '>>' : operator has no effect; expected operator with side-effect d:\project\dropcalcdropimport\dropcalcdropimport\Form1.h(198) : error C2065: 'endl' : undeclared identifier Build log was saved at "file://d:\Project\DropCalcDropImport\DropCalcDropImport\Release\BuildLog.htm" DropCalcDropImport - 8 error(s), 1 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Link to comment Share on other sites More sharing options...
monoceres Posted January 1, 2010 Share Posted January 1, 2010 (edited) You're doing something wrong.Just the fact that the errors are coming from a .h definitely tells me you're doing something wrong. (generally .h files should contain declarations, not definitions).Edit: Really!? STL is an incredible powerful and useful addition to C++. It's usually the first thing people learn when they reading about C++. Edited January 1, 2010 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Negat1ve Posted January 1, 2010 Author Share Posted January 1, 2010 array<Char>^ test1; String^ test = "10"; test1 = test->ToCharArray(); int test2 = test1[0]; it WORKS =D i did it my self . no google or something =D Link to comment Share on other sites More sharing options...
monoceres Posted January 1, 2010 Share Posted January 1, 2010 What. The. Hell. Was. That? Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Valik Posted January 1, 2010 Share Posted January 1, 2010 It looks like Managed C++. Yet another person who doesn't know what language they are using, apparently. Link to comment Share on other sites More sharing options...
Negat1ve Posted January 1, 2010 Author Share Posted January 1, 2010 I know that it is managed C++ .. and finaly found simple solution for conversion Single::Parse() Link to comment Share on other sites More sharing options...
Valik Posted January 1, 2010 Share Posted January 1, 2010 I know that it is managed C++ .. and finaly found simple solution for conversionIt would have been helpful if you had mentioned that earlier. Managed C++ != C++. They are very different. You said and I quote:his is for autoit .. i need to know how to do it in C++ ( MS Visual C++ 2008 )That is wrong, you need to know how to do it in Managed C++. A very important detail. Link to comment Share on other sites More sharing options...
Negat1ve Posted January 1, 2010 Author Share Posted January 1, 2010 ok sorry then =) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now