Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Jak przekazać zmienną tekstową, jako zmienna liczbowa.

Ostatnio zmodyfikowano 2012-12-14 19:45
Autor Wiadomość
Forczek
Temat założony przez niniejszego użytkownika
» 2012-12-13 20:11:24
error: expected '>' before 'potrzebne'
error: expected '(' before 'potrzebne'
error: expected ')' before ';' token
error: no match for 'operator>' in 'potrzebne > skladnik[ 0 ]'
Mniej więcej coś takiego
P-70953
f0g
» 2012-12-14 19:45:54
String to int:
C/C++
#include <iostream>
#include <sstream>

int main()
{
    using namespace std;
   
    string s = "1234";
    stringstream ss( s ); // Could of course also have done ss("1234") directly.
   
    int i;
    ss >> i;
    cout << i << endl;
   
    return 0;
}

Int to string:
C/C++
#include <sstream>

string convertInt( int number )
{
    stringstream ss; //create a stringstream
    ss << number; //add number to the stream
    return ss.str(); //return a string with the contents of the stream
}
P-71010
1 2 « 3 »
Poprzednia strona Strona 3 z 3