yang
April 26th, 1999, 09:23 AM
I have some problems with my program (in C++). Anyone can help me out??
|
Click to See Complete Forum and Search --> : need help in C++ yang April 26th, 1999, 09:23 AM I have some problems with my program (in C++). Anyone can help me out?? Mike Weber April 26th, 1999, 10:23 AM Can you be more specific? yang April 26th, 1999, 10:55 AM What I need to do is that parsing the given input file for a specific character and then writing the words that were found with that character to the given output file. (both of input and output files are text files). I got some source codes from the net. However, it didn't work. Would you mind take a look by any chance. Thank you! void LocateCharAux(FILE *pik_in, FILE *TB, TCHAR findchar) { TCHAR findChar; BOOL m_Top = TRUE; BOOL m_Bottom = TRUE; if (m_Top) { findChar = (TCHAR)'T'; } else if (m_Bottom) { findChar = (TCHAR)'B'; } if (!pik_in || !TB) return; static const TCHAR seps[] = _T(" \t\n"); TCHAR buf[256]; TCHAR *token; while (fgets(buf, sizeof(buf)/sizeof(buf[0]), pik_in)) { // tokenize the line into words token = _tcstok(buf, seps); while (token != NULL) { if (_tcschr(token, findChar) != NULL) { _ftprintf(TB, _T("%s\n"), token); } // While there are tokens in "string" token = _tcstok(NULL, seps); } } } void LocateChar(LPCTSTR text2, LPCTSTR strTB, BOOL bTop) { TCHAR findChar = bTop ? (TCHAR) 'T' : (TCHAR)'B'; FILE *pik_in = NULL, *TB = NULL; pik_in = _tfopen(text2, _T("r")); if (pik_in != NULL) { TB = _tfopen(strTB, _T("w")); if (TB != NULL) { LocateCharAux(pik_in, TB, findChar); fclose(TB); } fclose(pik_in); } } codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |