I have a function in a class but whenever i try to modify one of the parameters in the function the program crashes.
This is my .h file:
This is my code for the GetValue() function:Code:class InfFiles { public: char* GetValue(char option[50]); void SetValue(char option[50], char Value[50]); char fileName[100]; };
If i put "strcat(option, " = ");" or "option[0] = NULL" into the GetValue function the program will crash. Also if the GetValue function returns "option" i get a returned value but if it returns "searchResult" it just returns NULL.Code:#include <windows.h> #include <fstream.h> #include "class - inf.h" char* InfFiles::GetValue(char option[50]) { ifstream file; file.open(fileName, ios::in); char searchResult[100]; int size = strlen(option); bool optionFound = false; while(!file.eof()) { file.getline(searchResult, 100); searchResult[size] = NULL; if(strcmp(option, searchResult)==0) { optionFound = true; return searchResult; } } return NULL; }
Please help me
thanks



LinkBack URL
About LinkBacks



