- #1
taupune
- 25
- 0
Hi ,I am doing some strings operation but it seems that compiler is doing extra copping.
Can someone else verify this or is it my sloppy coding?
Also I had to write
std::cin ...etc otherwise compiler would like the code without that expression in main function.
I am using Visual studio 2010.
#include <iostream>
using namespace std;
#include "string.h"
void disect (char TheMessage[], int startloc, char messagepart[], int messagelength);
void ResultCodeTable ( char Result[]);
int main ()
{
char test[3];
char message [140];
char enter;
std::cout << "hello enter the mesage: "<<endl;
std::cin>> message;
std:: cout<<"uncopied string: " <<test<<endl;
disect(message,3,test, 3);
std:: cout<<"copied string: " <<test<<endl;
std::cout<<"this is the message: "<<message<<endl;
std::cin>> enter;
return (0);
}
//Dissect cuts the mesage into several parts , where each part provides the separate meaning of itself
void disect (char TheMessage[], int startloc, char messagepart[], int messagelength)
{
cout<< "this is pre message part inside function printing: "<<messagepart<<endl;
cout<<"start loc is:"<<startloc<<" end loc is "<<messagelength<<endl;
for ( int i = 0; i<messagelength; i++)
{
messagepart= TheMessage[startloc];
startloc++;
cout<<"message part array : "<<messagepart<<endl;
cout<<"message original mesage : "<<TheMessage<<endl;
}
cout<< "end of function execution inside function printing: "<<messagepart<<endl;
}
Can someone else verify this or is it my sloppy coding?
Also I had to write
std::cin ...etc otherwise compiler would like the code without that expression in main function.
I am using Visual studio 2010.
#include <iostream>
using namespace std;
#include "string.h"
void disect (char TheMessage[], int startloc, char messagepart[], int messagelength);
void ResultCodeTable ( char Result[]);
int main ()
{
char test[3];
char message [140];
char enter;
std::cout << "hello enter the mesage: "<<endl;
std::cin>> message;
std:: cout<<"uncopied string: " <<test<<endl;
disect(message,3,test, 3);
std:: cout<<"copied string: " <<test<<endl;
std::cout<<"this is the message: "<<message<<endl;
std::cin>> enter;
return (0);
}
//Dissect cuts the mesage into several parts , where each part provides the separate meaning of itself
void disect (char TheMessage[], int startloc, char messagepart[], int messagelength)
{
cout<< "this is pre message part inside function printing: "<<messagepart<<endl;
cout<<"start loc is:"<<startloc<<" end loc is "<<messagelength<<endl;
for ( int i = 0; i<messagelength; i++)
{
messagepart= TheMessage[startloc];
startloc++;
cout<<"message part array : "<<messagepart<<endl;
cout<<"message original mesage : "<<TheMessage<<endl;
}
cout<< "end of function execution inside function printing: "<<messagepart<<endl;
}