I am quite a novice in c++ programming
i am tryling to learn it by myself but i'm not be able to do theing
could any one help me
My header file
#include #include #include #include #include //using namespace std;
//Declaring the global varialbles that will be visible to all the functions.
class ScrObj
{
ScrObj();
~ScrObj();
//Declaring the fuctions::::Fuction prototypes
public :
void FormatPrint(int format, const char *Str);
private:
void PrintOut(const char *StrOut);
void MakeStream(const char *FinalStr);// this is the actual fuction that display
My Cpp file
#include "CScreen.h"
ScrObj::ScrObj;
{
void FormatPrint(int format, const char *Str)
{//breaking th e main task into smaller subtasks
PrintOut(Str);
// FormatOut(format);
}//end formatPrint function
void PrintOut(const char *StrOut)
{
const int LIMIT = 15;//This LIMIT defines the maximum length of the string
if (strlen(StrOut)>0)
{
if (strlen(StrOut)<= LIMIT + 1)
{
MakeStream(StrOut);
}
else if(StrOut[LIMIT]==' ' || StrOut[LIMIT]=='
' || StrOut[LIMIT]=='.' )//|| any other predefined special character
{
// The code segment that allocates for the first part of the string
char *temp4=(char*)malloc(LIMIT+1);//[pointend-1];
memset(temp4, 0, LIMIT+1);
strncpy(temp4, StrOut, LIMIT+1);
MakeStream(temp4);
//CODE SEGMENT THEAT WILL ALLOCATE FOR THE SECOND STRING
int ArrSize1=strlen(StrOut)-LIMIT;
char *temp5=(char*)malloc(ArrSize1);//[pointend-1];
memset(temp5, 0, ArrSize1);
int k=0;
k=LIMIT;
char swap1;
int l=0;
for(k=LIMIT+1; k<=(strlen(StrOut))-1; k++)
{
swap1=StrOut[k];
temp5[k]=swap1;
l++;
}
PrintOut(temp5);
}
else
{
int pointend;
pointend=LIMIT;
for (pointend=LIMIT; pointend>0; pointend--)
{
if (StrOut[pointend]==' ')
{
// CODE SEGMENT THAT ALLOCATE FOR THE FIRST STRNG
char *temp1=(char*)malloc(pointend+1);//[pointend-1];
memset(temp1, 0, pointend+1);
strncpy(temp1, StrOut, pointend);
MakeStream(temp1);
//CODE SEGMENT THEAT WILL ALLOCATE FOR THE SECOND STRING
int ArrSize=strlen(StrOut)-pointend;
char *temp3=(char*)malloc(ArrSize);
memset(temp3, 0, ArrSize);
int i=0;
i=pointend;
char swap;
int j=0;
for(i=pointend+1; i<=(strlen(StrOut))-1; i++)
{
swap=StrOut[i];
temp3[j]=swap;
j++;
}
PrintOut(temp3);
break;
}
else
{
}
}
}
}
}//end PrintOut function
void MakeStream(const char *FinalStr)// this is the actual fuction that displaya
{
cout<<""<<FinalStr<<"
";
}
}Scrobj::bla()
Help plaese
Comments
: i am tryling to learn it by myself but i'm not be able to do theing
: could any one help me
:
: My header file [red]- I assume it is called CScreen.h ?? [/red]
: [code]
: #include
: #include
: #include
: #include
: #include
:
:
: //using namespace std;
:
: //Declaring the global varialbles that will be visible to all the functions.
: class ScrObj
: {[red]// need to make constructor public
public: [/red]
: ScrObj();
: ~ScrObj();
: //Declaring the fuctions::::Fuction prototypes
: public :
: void FormatPrint(int format, const char *Str);
:
:
: private:
: [red]// you probably want this to be public also...[/red]
: void PrintOut(const char *StrOut);
: void MakeStream(const char *FinalStr);// this is the actual fuction that display
/ [red] Need to close out the declaration
}; [/red]
[/code]
: My Cpp file
:
:
: [code]
: #include "CScreen.h"
[red]// You define each method seperately, not as a class group
// You just need to put the class scope before the method name
: // delete this---> [/red]ScrObj::ScrObj;
: // [red] and this--> [/red] {
: void [red]ScrObj::[/red]FormatPrint(int format, const char *Str)
: {//breaking th e main task into smaller subtasks
: PrintOut(Str);
: // FormatOut(format);
: }//end formatPrint function
:
[red] // Do same thing here[/red]
: void PrintOut(const char *StrOut)
: {
: const int LIMIT = 15;//This LIMIT defines the maximum length of the string
:
:
: if (strlen(StrOut)>0)
: {
: if (strlen(StrOut)<= LIMIT + 1)
: {
: MakeStream(StrOut);
: }
: else if(StrOut[LIMIT]==' ' || StrOut[LIMIT]=='
' || StrOut[LIMIT]=='.' )//|| any other predefined special character
:
: {
: // The code segment that allocates for the first part of the string
: char *temp4=(char*)malloc(LIMIT+1);//[pointend-1];
: memset(temp4, 0, LIMIT+1);
: strncpy(temp4, StrOut, LIMIT+1);
: MakeStream(temp4);
:
: //CODE SEGMENT THEAT WILL ALLOCATE FOR THE SECOND STRING
: int ArrSize1=strlen(StrOut)-LIMIT;
:
:
:
:
: char *temp5=(char*)malloc(ArrSize1);//[pointend-1];
: memset(temp5, 0, ArrSize1);
: int k=0;
: k=LIMIT;
: char swap1;
: int l=0;
: for(k=LIMIT+1; k<=(strlen(StrOut))-1; k++)
: {
: swap1=StrOut[k];
: temp5[k]=swap1;
: l++;
: }
:
: PrintOut(temp5);
: }
: else
: {
: int pointend;
: pointend=LIMIT;
: for (pointend=LIMIT; pointend>0; pointend--)
: {
: if (StrOut[pointend]==' ')
: {
: // CODE SEGMENT THAT ALLOCATE FOR THE FIRST STRNG
: char *temp1=(char*)malloc(pointend+1);//[pointend-1];
: memset(temp1, 0, pointend+1);
: strncpy(temp1, StrOut, pointend);
: MakeStream(temp1);
:
: //CODE SEGMENT THEAT WILL ALLOCATE FOR THE SECOND STRING
: int ArrSize=strlen(StrOut)-pointend;
: char *temp3=(char*)malloc(ArrSize);
: memset(temp3, 0, ArrSize);
: int i=0;
: i=pointend;
: char swap;
: int j=0;
: for(i=pointend+1; i<=(strlen(StrOut))-1; i++)
: {
: swap=StrOut[i];
: temp3[j]=swap;
: j++;
: }
:
: PrintOut(temp3);
: break;
: }
:
: else
: {
:
: }
: }
:
: }
: }
: }//end PrintOut function
:
: [red]// and do same thing here[/red]
: void MakeStream(const char *FinalStr)// this is the actual fuction that displaya
: {
:
: cout<<""<<FinalStr<<"
";
:
:
: }
:
: //[red] delete this[/red]}Scrobj::bla()
: [/code]
:
:
:
: Help plaese
: