Changed the char to a string so it should be able to compare it.
I do not completely understand what you mean by the second paragraph though. I need <stdio.h> for the scanf(). I thought the header files were essentially the same. :/
Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main()
{
string chain;
string input;
int done = 0;
int compare;
string YN;
while (done==0)
{
cout << "Input next element in chain: " << endl;
scanf("%s", input);
chain = chain + input;
cout << "Done? (Y/N) " << endl;
scanf("%s", YN);
if (strcmp(YN,"Y") == 0)
done = 1;
}
cout << chain << endl;
return 0;
}
Errors:
Code:
C:\CPP\ListC\main.cpp||In function 'int main()':|
C:\CPP\ListC\main.cpp|20|warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime|
C:\CPP\ListC\main.cpp|20|warning: format '%s' expects type 'char*', but argument 2 has type 'int'|
C:\CPP\ListC\main.cpp|24|warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime|
C:\CPP\ListC\main.cpp|24|warning: format '%s' expects type 'char*', but argument 2 has type 'int'|
C:\CPP\ListC\main.cpp|26|error: cannot convert 'std::string' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)'|
C:\CPP\ListC\main.cpp|13|warning: unused variable 'compare'|
||=== Build finished: 1 errors, 5 warnings ===|