This is the code of my program:
#include stdio.h
#include stdlib.h
#include string.h
int main ()
{
string a;
string help = "-h";
printf("Por favor introduzca la orden. Si desea ver la ayuda introduzca -h");
scanf(&a);
if ( a == help)
{
printf("\n\nComandos y expresiones de iptables:");
}
else
{
system("iptables %c && iptables -L -v -n", a);
}
return 0;
}
The issue is that I can not get either the if or the string variables to work since gcc tells me this:
TerFirewall.cpp: In function ‘int main()’:
TerFirewall.cpp:5:2: error: ‘string’ was not declared in this scope
string a;
TerFirewall.cpp:6:9: error: expected ‘;’ before ‘help’
string help = "-h";
TerFirewall.cpp:8:9: error: ‘a’ was not declared in this scope
scanf(&a);
TerFirewall.cpp:9:12: error: ‘help’ was not declared in this scope
if ( a == help) {
I have tried several times changing nimiedades as instead of using string for the declaration of variables, use char but says the same of the error "string". I also tried trying another way to store the text in the variable string
but if I leave single quotes it follows the same error and if I take them out it says that the variable h has not been declared.
And with if
is something similar because it does not recognize the help
. And with scanf()
I do not know how to do since I've seen in other forums that it's better than getchar()
, but I do not know.