online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <cstring> using namespace std; bool compa(char* p){ int L; L = strlen(p); if(*p == '4' && L == 16) cout<<"La tarjeta es Visa\n"; else if(*p == '5' && L == 16) cout<<"La tarjeta es MasterCard\n"; else if(*p == '3' && L == 15) cout<<"La tarjeta es American Express\n"; else{ cout<<"La tarjeta NO es valida\n"; return false; } return true; } void verificar(char* p){ int i, n=strlen(p), dp, s=0; for(i=n-2; i>=0; i=i-2){ dp = (*(p+i)-48)*2; if (dp >= 10) dp = dp%10+dp/10; *(p+i) = dp+48; } for(i=0; i<n; i++){ s = s+*(p+i)-48; } if (s%10 == 0) cout<<"La tarjeta SI es valida\n"; else cout<<"La tarjeta NO es valida\n"; } int main(){ char* p; p = new char[17]; cout<<"Escriba un numero: "; cin.getline(p, 17); if (compa(p)) verificar(p); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue