S
Sh0t
Everytime i compile this program the pointer seems to lose its data??
*fileToFix is suppose to change after entering fixFile() as a param
program ------------------------------------------------
#include <iostream.h>
void fileFix(char*[], char type);
int main() {
char* fileToFix[30];
*fileToFix = "file";
fileFix(fileToFix, 'g');
cout << flush << endl;
cout << "Finished File: " << *fileToFix << endl;
return 0;
}
void fileFix(char *fileToFix[], char type) {
cout << "*fileToFix = " << *fileToFix << endl;
int pos = 0;
bool goOn = true;
char suff[] = {'.','d','a','t'};
char fileFix[30];
char fCopy[30];
fCopy[0] = type;
strcpy(fileFix, *fileToFix);
for (int i = 1; i < 30; i++)
fCopy = fileFix[i-1];
for (int i = 0; i < 30; i++) {
if (((int)fCopy < 65) || ((int)fCopy > 90 && (int)fCopy < 97) ||
((int)fCopy > 122)) {
goOn = false;
pos = i;
}
if (!goOn)
break;
}
for (int j = 0; j < 4; j++)
fCopy[pos+j] = suff[j];
for (int i = pos+4; i < 30; i++)
fCopy = '\0';
*fileToFix = fCopy;
cout << "end: *fileToFix = " << *fileToFix << endl;
}
end of program -----
please helppppppppppppp
carl
*fileToFix is suppose to change after entering fixFile() as a param
program ------------------------------------------------
#include <iostream.h>
void fileFix(char*[], char type);
int main() {
char* fileToFix[30];
*fileToFix = "file";
fileFix(fileToFix, 'g');
cout << flush << endl;
cout << "Finished File: " << *fileToFix << endl;
return 0;
}
void fileFix(char *fileToFix[], char type) {
cout << "*fileToFix = " << *fileToFix << endl;
int pos = 0;
bool goOn = true;
char suff[] = {'.','d','a','t'};
char fileFix[30];
char fCopy[30];
fCopy[0] = type;
strcpy(fileFix, *fileToFix);
for (int i = 1; i < 30; i++)
fCopy = fileFix[i-1];
for (int i = 0; i < 30; i++) {
if (((int)fCopy < 65) || ((int)fCopy > 90 && (int)fCopy < 97) ||
((int)fCopy > 122)) {
goOn = false;
pos = i;
}
if (!goOn)
break;
}
for (int j = 0; j < 4; j++)
fCopy[pos+j] = suff[j];
for (int i = pos+4; i < 30; i++)
fCopy = '\0';
*fileToFix = fCopy;
cout << "end: *fileToFix = " << *fileToFix << endl;
}
end of program -----
please helppppppppppppp
carl