I know you can use scanf and get a character to use in an if clause, however, is there a way to do this with a string?
e.g.
printf("enter 'foo' to do 'bar', otherwise enter 'hay' to do 'wire');
scanf("%string", &stringNAME); //this is the part where I have no idea what to do
if (stringNAME == 'foo'){do bar} //here, issues occur with multicharacter character :/
if (stringNAME == 'hay'){do wire}
You’ve almost got it, just a few tweaks.
Note the number in the scanf, the 9. That should be one less (Or smaller) than the size of your input string. Otherwise you risk a buffer overflow, which is nasty business.
fgetsis a better choice, because you are forced to limit the number of characters. This is how you would do that (Just replace thescanfline)