Deprecated: Assigning the return value of new by reference is deprecated in /www/wwwroot/shabab.ps/public_html/vb/showthread.php on line 639

Deprecated: Assigning the return value of new by reference is deprecated in /www/wwwroot/shabab.ps/public_html/vb/showthread.php on line 1041

Deprecated: Assigning the return value of new by reference is deprecated in /www/wwwroot/shabab.ps/public_html/vb/showthread.php on line 1046

Deprecated: Assigning the return value of new by reference is deprecated in /www/wwwroot/shabab.ps/public_html/vb/showthread.php on line 1518

Deprecated: Assigning the return value of new by reference is deprecated in /www/wwwroot/shabab.ps/public_html/vb/showthread.php on line 1523
Help Me Plz in My C++ Assignment - منتديات شباب فلسطين
نحن مع غزة
قديم 06-13-2007, 03:31 AM   #1
محمود
..{ مديــــــر عــــام }..
 
الصورة الرمزية محمود
عيد فطر سعيد ,,

قوة السمعة: 50 محمود has a reputation beyond reputeمحمود has a reputation beyond reputeمحمود has a reputation beyond reputeمحمود has a reputation beyond reputeمحمود has a reputation beyond reputeمحمود has a reputation beyond reputeمحمود has a reputation beyond reputeمحمود has a reputation beyond reputeمحمود has a reputation beyond reputeمحمود has a reputation beyond reputeمحمود has a reputation beyond repute

افتراضي رد: Help Me Plz in My C++ Assignment

اسف اختي بس كانت الكهرب قاطعه

شوفي هيك

#include<iostream> //for cin,cout
#include<fstream> //for file processing functions
#include<cctype> //for isalpha(), isdidgit(),....etc. functions
using namespace std;

void outputNumberOfLines(const char *inputFileName , const char *outputFileName);
void outputNumberOfWords(const char *inputFileName , const char *outputFileName);
void outputNumberOfLetters(const char *inputFileName , const char *outputFileName);
void outputNumberOfDigits(const char *inputFileName , const char *outputFileName);
void outputNumberOfPrintableCharacters(c onst char *inputFileName , const char *outputFileName);
int getMenuChoice();

char infile[256]; // Input File
char outfile[256];// Output File


int main()
{




//Optain desired option from user
switch(getMenuChoice())
{
case 1:
outputNumberOfLines(infile,outfile) ;
break;
case 2:
outputNumberOfWords(infile,outfile) ;
break;
case 3:
outputNumberOfLetters(infile,outfil e);
break;
case 4:
outputNumberOfDigits(infile,outfile );
break;
case 5:
outputNumberOfPrintableCharacters(i nfile,outfile);
break;
case 6:
/*


exit(1);

*/

break;
}
cout<<"Result was printed out to "<<outfile<<endl;



return 0;


}

int getMenuChoice()
{
//Choice to be entered by user
int ch;
cout<<"\t\tFile Processing"<<endl
<<"\t\t==============="<<endl
<<endl
<<"1- Number of Lines"<<endl
<<"2- Number of Words"<<endl
<<"3- Number of Lettters"<<endl
<<"4- Number of Digits"<<endl
<<"5- Number of Printable ASCII Characters"<<endl
<<"6- Quit"<<endl;

cout<<">";
cin>>ch;

cout<<endl;

cout<<"You Chose Menu Option #"<<ch<<endl;
cout<<"Enter your input file name: ";cin>>infile;
cout<<"Enter your output file name: ";cin>>outfile;


//Check if user entered invalid choice number
if(ch<1 || ch>6)
{
cout<<"No such option. Please enter a number from the list!"<<endl;
return getMenuChoice();
}
else
return ch;



}
void outputNumberOfLines(const char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios ::out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char line[1024]; // a line with max length 1024

//This extracts one line a time
inputFile.getline(line,1024);

count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Lines="<<count<<endl;

//closing files
inputFile . close ();
outputFile . close ();
}
void outputNumberOfWords(const char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios :: out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char line[1024]; // a line with max 1024

//This extracts one word a time
inputFile>>line;

//don't count single letters
if(strlen(line)>1)
count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Words="<<count<<endl;

//closing files
inputFile . close ();
outputFile . close ();
}
void outputNumberOfLetters(const char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios :: out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char c; // a line with max 1024

//This extracts one word a time
inputFile.get(c);

//count only alphabet letters
if(isalpha(c))
count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Letters="<<count<<endl;

//closing files
inputFile . close ();
outputFile . close ();
}
void outputNumberOfDigits(const char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios :: out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char c; // a line with max 1024

//This extracts one word a time
inputFile.get(c);

//count only digits letters
if(isdigit(c))
count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Digits="<<count<<endl;

//closing files
inputFile . close ();
outputFile . close ();
}
void outputNumberOfPrintableCharacters(c onst char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios :: out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char c; // a line with max 1024

//This extracts one word a time
inputFile.get(c);

//count only printable chars
if(isprint(c))
count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Printable Charachters="<<count<<endl;

//closing files
inputFile.close ();
outputFile.close ();
}
  اقتباس المشاركة
قديم 06-13-2007, 08:14 AM   #2
Palestinian Rose
I ♥ SHABAB
 
الصورة الرمزية Palestinian Rose

قوة السمعة: 6 Palestinian Rose will become famous soon enough

Question رد: Help Me Plz in My C++ Assignment

يعطيك العافية يا أخ محمود

بس و الله بصراحة الكود لساتو متل ما هو !! و عم يعطيني نفس النتائج اللي أنا عملتها من أول !!!!
يعني لسه المشاكل اللي فيه موجود !!!
يمكن انت حاولت تضيف Quit للكود ، بس برضو ال program ما بيعمل Quit لما تختار الخيار السادس اللي هو Quit !!!!!!!

عالعموم ، اذا ما حد عرف يساعدني مش مشكلة !! الله يعطيكم العافية على كل حال
انا بحاول أزبطه مرة تانية ، أو بسأل أي حد تاني يساعدني


شكرًا كتير للجميع
  اقتباس المشاركة
إضافة رد


الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1)
 
أدوات الموضوع
انواع عرض الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة

الانتقال السريع


الساعة الآن 05:09 PM.