I've been working on this HTML case conversion program for about an hour now, but i'm stumped.
This is the main program loop. However, all that gets outputted to the fileOut is a bunch of garbage. On top of that, the test for fileIn.eof() doesn't seem to be working, as the program loops forever and fills fileOut with endless crap. I probably have to flush something somewhere, but I'm not too up on this subject.Code:fileIn.open(g_pcInputFile, ios::in); fileOut.open(g_pcOutputFile, ios::out | ios::trunc); if (fileIn.fail()) { cout << "\tFailed to open input file, please ensure path and filename are correct.\n"; getch(); return 1; } do { char pszBuffer[512]; fileIn.getline(pszBuffer, 511, '\n'); char *pszTag = strchr(pszBuffer, '<'); while (pszTag != NULL) { cout << pszTag << endl << endl << endl; for (int i = 0; i < strlen(pszTag) + 1; i++) { if (pszTag[i] != '>') { if (g_bGoingUpper) { pszTag[i] = toupper(pszTag[i]); } else { pszTag[i] = tolower(pszTag[i]); } } else { break; } } cout << pszTag << endl << endl << endl; pszTag = strchr(pszBuffer + (pszTag - pszBuffer + 1), '<'); } // cout << pszTag << endl << endl << endl; fileOut.write(pszBuffer, 512); } while (!fileIn.eof()); fileIn.close(); fileOut.close();
Basically, I open an HTML file, read in a line, find the tags, convert them to either uppercase or lowercase, output it to the output file and repeat. I did this in MFC using the CString and CFile classes, but I lost the source to that
Edit:: Heh, subscripting with variable i confuses the board![]()



LinkBack URL
About LinkBacks



