0

Having issues opening a .cpp created in Visual studio in other compilers. My instructor relies on everything but visual studio, and gets garbage when opening a visual studio created cpp file.

image of visual studio created c++ file in Dev-Cpp:

image of visual studio created c++ file in Dev-Cpp

sticky bit
  • 36,626
  • 12
  • 31
  • 42
  • 2
    how is this file encoded? have you opened it with notepad++ to see if it works okay? see https://softwareengineering.stackexchange.com/questions/187169/how-to-detect-the-encoding-of-a-file – aaron Sep 11 '18 at 00:31

1 Answers1

0

You should check the character encoding of the .cpp file, if you used Visual Studio to create it, it may be UTF-8 with the byte order mark (BOM) sequence to the beginning of the file.
You may use a binary|hexadecimal file viewer to see if the file starts with BOM sequence.

In Visual Studio, if you want to save a file with other encodings select Save as and extend the save button in file dialog and select Save with encoding.
If you want to remove this setting permanently just open File menu and select Advanced save options and there you should select UTF-8 without signature.

See this SO question and also this other one for more information and details or alternative solutions.

roalz
  • 2,699
  • 3
  • 25
  • 42