Aug 15, 2009 at 5:12am UTC
hi could some body help me?
im making a program that writes in a file.txt
how can i compare my "char x" to another char?
#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;
int main()
{
char x[100];
char y[100];
cout << "enter title" << endl;
gets(y);
ofstream rave(y, ios::out);
cout << "enter word" << endl;
do
{
gets(x);
if (x!= (?)) // <= i need something that "char x" could be compare to so that my if comd will execute
{
rave << x;
}
}while(x != (?)); // <= same above
rave.close();
}
Aug 15, 2009 at 7:22am UTC
I might be wrong but I think by using != it would have to be the exact char you specify in (?)
I am pretty new to C++ but i use != as a sentinel statement. Like if the user enters (x != -1) when the user hits -1 the program ends there.
Hope that might help a little. Or atleast maybe get you thinking of a better way to solve it :)
Aug 16, 2009 at 2:30pm UTC
wew tnx hamsterman you fill in the part that i was missing.