Aug 16, 2012 at 1:39am UTC
i've been having a problem with this code i wrote, in which the system founds a problem within it and it closes the program. The code is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#include <iostream>
#include <fstream>
using namespace std;
int main(){
int row;
char *puntero[row];
string line;
fstream log;
log.open("C:/log.txt" , ios::out | ios::in | ios::app);
if (log.is_open()){
getline(log, line);
line = *puntero;
for (row= 0; row<80; row++){
if (*puntero[row] == 's' ){
*puntero[row]== 'd' ;
}
}
log.close();
printf(*puntero, "\n" );
}
}
any help? i want to take the line from the file and search for the S's and change them for D's, any suggestion?
Last edited on Aug 16, 2012 at 1:43am UTC
Aug 16, 2012 at 3:46am UTC
SirSen,
*puntero[row]== 'd' ;
That is a test for equality, did you really want assignment instead?
Also, are you mixing a C approach with a C++ approach? You are assigning a string to a char array, why not use the C++ algorithms on the string. If you have to do C code, then just use the char array.
Aug 17, 2012 at 1:23am UTC
oh thank u, i knew i was mixing up somewhere but i didnt realize where