João Carlos 1916 0 Report post Posted October 20, 2017 (edited) Como posso fazer esse codigo funcionar? #include <iostream> #include <fstream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> using namespace std; int main() { char u[1000]; char k[40]; cout << "digite a letra certa: "; cin >> u; strcpy(k, ""); strncat(k, u +1, 3); if(k == "g"){cout << "acertou";} else{cout << "errou";} return 0; } Edited October 20, 2017 by João Carlos 1916 Quote Share this post Link to post Share on other sites
0 Gustavo Oliveira 0 Report post Posted October 26, 2017 Não se compara string dessa forma dentro do if, use a strcmp, abraços. Quote Share this post Link to post Share on other sites
Como posso fazer esse codigo funcionar?
Share this post
Link to post
Share on other sites