Forum Replies Created
- AuthorPosts
- 050449Participant
Hi. I have a new problem now.
I am using C++ builder 2009 and i cannot make “tmaskedit” to show characters as “*” like in web
Can anyone help me?
050449Participantthanks.and what about read() function ??
050449Participantups problem. problem with read not solved it shows each word in new line
050449ParticipantOh thanks it works well.
but can you explain what “cin.get()” means??
and what it used for?and now i have to think how to remove confirmation
050449Participantthanks it works ok.
now code is12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273<br />#include <iostream><br />#include <fstream><br />#include <string.h><br />#include <stdlib.h><br />#define MAX_NAME 1000<br /><br /><br />using namespace std;<br />char sendtext;<br />char username;<br /><br />void read(){<br />system("cls");<br />cout << "You autorised as:" << username << "n";<br />ifstream in;<br />in.open("msngr.txt");<br />if (!in) {<br />cout << "Input file cannot be opened.n";<br />//return(1);<br />}<br />char str[20000];<br />while (!in.eof()) {<br />in >> str;<br />cout << str << "n";<br />strcpy(str, "");<br />}<br />cout << "n";<br />in.close();<br /><br />}<br />void write ()<br />{<br /><br />char choice;<br />cout << "do you want to input data to file ( y or n )" << endl;<br />cin >> choice;<br />cin.get(); //get newline<br />while ( choice != 'y' && choice != 'n' )<br />{<br />cout << "bad choice!" << endl;<br />cout << "do you want to input data to file ( y or n )" << endl;<br />cin >> choice;<br />cin.get(); //get newline<br />}<br /><br />if ( choice == 'y' )<br />{<br />char inputText [ MAX_NAME ];<br />cout << "enter input text: " << endl;<br />cin.getline ( inputText , MAX_NAME , 'n' );<br /><br />ofstream outputFile;<br />//PUT YOUR DATA FILE NAME HERE!<br />outputFile.open ( "msngr.txt" , ios::app );<br />outputFile << inputText << endl;<br />outputFile.close();<br />read();<br />write();<br />}<br /><br />}<br />main(){<br />cout << "Enter your username: ";<br />cin >> username;<br />read();<br />write();<br /><br /><br />return (0);<br />}<br /><br /></fstream></iostream>but there is some problems too.
when i enter username it writes only first the letter of the username and all other letters understands as answer to the confirmation and writesYou autorised as:N
do you want to input data to file ( y or n )
bad choice!
do you want to input data to file ( y or n )
bad choice!
do you want to input data to file ( y or n )and when it shows the data of the file it puts n after all words and when i write “something is wrong”
it shows
something
is
wrong
but in file everything is ok050449Participantif ( sendtext )
{
FILE * pFile;
char yazi[] = {sendtext , ‘n’};
pFile = fopen ( “msngr.txt” , “a+” );
fwrite (yazi , 1 , sizeof(yazi) , pFile );
fclose (pFile);
read(); //take these out!
write();
}if i take this out my new text will not appear
050449Participanti defined MAX_SIZE and this problem solved but now it shows me
invalid conversion from
char’ to
const char*’
initializing argument 2 of `char* strcpy(char*, const char*)’050449Participantthanks for all but there is error
`MAX_SIZE’ undeclared (first use this function)
050449Participantthanks for all but there is error
`MAX_SIZE’ undeclared (first use this function)
- AuthorPosts