Zmienne typu std::string i printf
Ostatnio zmodyfikowano 2011-12-22 21:53
matoł115 Temat założony przez niniejszego użytkownika |
Zmienne typu std::string i printf » 2011-12-22 21:35:47 Witam! Mam następujący problem: #include <cstdio> #include <string> using namespace std; int main() { int n, k, i, x, y, z; scanf( "%d", & n ); string a[ n ], p; for( i = 0; i < n; i++ ) { scanf( "%s", & a[ i ] ); } for( i = 0; i < n; i++ ) { printf( "%s", a[ i ] ); } return 0; }
Program zwraca: main.cpp:15:21: error: cannot pass objects of non-trivially-copyable type ‘struct std::string’ through ‘...’ Co z tym fantem zrobić? |
|
ison |
» 2011-12-22 21:53:32 std::string nie możesz wczytać scanfem, jeśli chodzi o wypisywanie to printf( "%s", a[ i ].c_str() ); |
|
« 1 » |