I am writing a function for the program that allows a student to copy a template text file. To see if the desired template is allowed for his or her class.
I am getting the "Comparison of the string with the literal result in the unspecified transaction" on 21 and 25 lines. I have done "cout <" to fix this,
#include & lt; Iostream & gt; #include & lt; String & gt; # Include & lt; Fstream & gt; using namespace std; // Template check // First check to see if the student template is allowed to use template at check () {// declared name name variable variable name [256]; Prompt for // User Input Cot & lt; & Lt; "Enter file name:"; // Cin User Input cin & gt; & Gt; Name; // Start check // CS 221 is the first template that you can not use (name == "/home/cs221Temp.txt") cout & lt; & Lt; "You do not have permission to use CS221 templates." // CS 321 is another template that you can not use other if (name == "/home/cs321Temp.txt") cout & lt; & Lt; "You do not have permission to use CS321 templates." / N "; // Someone else is fine (I comment since these because I'm just working on this function by myself) // copyTemplate (); Return 0; This statement
= "/home/cs221Temp.txt")
Compares the comparison of points (which is unlikely), not their contents
What exactly do you want
if (strncmp (name, "/ home / cs221Temp.txt", 256) == 0)
Or
std :: string name;
In your function
No comments:
Post a Comment