PDA

View Full Version : input/output guna textfile dalam c++


roswellboy118
21-08-03, 12:48 AM
tolong bagi contoh jap .. aku dah lupa lah .. tolong yerk ...

kurma
21-08-03, 10:02 AM
contoh camne.. aku pon dah lama tak layan c++ ni...
camni leh ke?
http://www.cplusplus.com/doc/tutorial/tut6-1.html

kurma
21-08-03, 10:03 AM
ni ada lagi
http://www.4p8.com/eric.brasseur/cppcen.html#l31

roswellboy118
21-08-03, 01:34 PM
thank kurma .... napa tak nampak mulut yerk .. :P

SebenEleben
31-08-03, 02:51 AM
#include<stdio.h>
#include<stdlib.h>

int main()
{
char str[80] = " sebeneleben\n";
file *fp;
if (( fp = fopen("myfile","w"))==NULL {
printf("fail tak leh bukak.\n");
exit(1);
}

return 0;

}


lebih kurang la.. aku maleh nak taip.. muehhahah... nie pun aku tgk dalam magazine kat pcworld.

Moderator's note : When pasting code please use the "PHP" tag

regna_anger
15-09-03, 01:32 PM
tu coding c .... serabut btulll ...aku lagik sukak c++ ... taruk library ... 3-4 ayat je siap..

SebenEleben
25-09-03, 05:15 PM
old fashion thing .. no harm.. do the same thing..

oxyn
01-10-03, 11:24 AM
ada lagi contoh ... songlap adik punya ....


//---------------------------------------------------------------------------
#include <iostream.h>
#include <fstream.h>

int main(void)
{
char cFileName[20] = "a:keyword.txt";
char dFileName[20] = "a:keys.txt";
int cMode = ios::in;
int dMode = ios::out;

fstream cFileIn = fstream(cFileName,cMode);
fstream cFileOut = fstream(dFileName,dMode);

char cChar;
int cCount = 0;
while(cFileIn.get(cChar))
{
if(cChar=='\n')
{
if(cCount<6)
{
cChar = '\t';
cCount ++;
}
else
{
cCount = 0;
}
}
cFileOut << cChar;
}

cFileOut.close();
cFileIn.close();

return 0;
}
//---------------------------------------------------------------------------