S
sjonca
I have the need to convert from a *ptr to an array[]. I'm using the
getpass(x) function that returns a *ptr. I want this converted to an
array[] in order to concatonate it with 4 other array[] strings. Here's
a snippet of the class created. Any help would be appreciated.
#include <iostream.h>
#include <string.h>
#include <math.h>
#define Space " "
class PassWD
{
public:
char *return_passwd() ;
char passwd(char *X, int) ;
char *oldp, *firn, *secn ;
};
char PassWD:
asswd(char *X, int num) //the *ptr is required and
{ //from the
getpass() func
if(num==1) { //the num is an arg
sent
strcpy(oldp,X) ; } //to delineate the
difference
else if(num==3) {
strcpy(firn,X) ; }
else if(num==5) {
strcpy(secn,X) ; }
return 0 ;
}
char *PassWD::return_passwd()
{
char *Newp = new char[50] ;
strcpy(Newp,oldp) ;
strcat(Newp,"/") ;
strcat(Newp,firn) ;
strcat(Newp,"/") ;
strcat(Newp,secn) ;
return Newp ;
}
getpass(x) function that returns a *ptr. I want this converted to an
array[] in order to concatonate it with 4 other array[] strings. Here's
a snippet of the class created. Any help would be appreciated.
#include <iostream.h>
#include <string.h>
#include <math.h>
#define Space " "
class PassWD
{
public:
char *return_passwd() ;
char passwd(char *X, int) ;
char *oldp, *firn, *secn ;
};
char PassWD:
{ //from the
getpass() func
if(num==1) { //the num is an arg
sent
strcpy(oldp,X) ; } //to delineate the
difference
else if(num==3) {
strcpy(firn,X) ; }
else if(num==5) {
strcpy(secn,X) ; }
return 0 ;
}
char *PassWD::return_passwd()
{
char *Newp = new char[50] ;
strcpy(Newp,oldp) ;
strcat(Newp,"/") ;
strcat(Newp,firn) ;
strcat(Newp,"/") ;
strcat(Newp,secn) ;
return Newp ;
}