Detailed Print – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Solved Problem!#CPP#5191

Problem Statement - File and string related header files

The following C++ code during compilation reports errors as follows:
Error: ‘ofstream’ not declared
Error: ‘strupr’ not declared
Error: ‘strcat’ not declared
Error: ‘FIN’ not declared
Write the names of the correct header files, which must be included to compile the code successfully:

void main()
{
  ofstream FIN("WISH.TXT");
  char TEXT2[]="good day";
  char TEXT1[]="John!";
  strupr(TEXT2);
  strcat(TEXT1, TEXT2);
  FIN<<TEXT1<<endl;
}

Click to open popup

Solution

ftream.h
string.h

Notes

ftream.h is required to handle
ofstream FIN(“WISH.TXT”);
FIN<<TEXT1<<endl;

string.h is required to handle
strupr(TEXT2);
strcat(TEXT1, TEXT2);