none
Why are my .cpp and/or .h files not opening in Visual Studio?

    Question

  • The problem I am having with my project(s) in visual studio is that I'll open an empty project, write code into my .h and .cpp files, save it, and then later when I try to open the code, only part or none of the program opens. Under Solution Explorer, I'll go under Source Files and Header files, double click on "file_name.cpp" or "file_name.h", but instead of opening in VS, Notebook opens with a blank page. How do I fix this and prevent it from occurring with future projects?

    Not sure if this is relevant to my problem but I am running Visual Studio 2015 on Windows 10 which is running on a virtual machine (VirtualBoxVM).



    Wednesday, April 5, 2017 3:52 AM

All replies

  • Hi Fab,

    thanks for posting here.

    >>The problem I am having with my project(s) in visual studio is that I'll open an empty project, write code into my .h and .cpp files, save it, and then later when I try to open the code, only part or none of the program opens.

    This forum is about c++ development. For your case, I will move it to vs general forum for better support.

    Your understanding and cooperation will be grateful.

    Best Regards,
    Sera Yu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 5, 2017 6:16 AM
  • Hi Fab.95,

    Welcome to the MSDN forum.

    Refer to your description, it looks like you can open .cpp and .h files when you created this new project, if you write code into them and save, double click those files and them are open with notebook (a blank page), right?

    If so, I want to know the detail steps to reproduce the above issue, like the template project that you chose, the code you typed into the .cpp and .h file, I will test it on in my VS 2015 to check if I can reproduce this issue or not.

    Meanwhile, please have a try with the following to troubleshot this issue:

    1. Please right click the .cpp or .h file under Solution Explorer and choose 'Open With...' and it should check 'C++ Source Code Editor (Default)', if not, you can select this option and click 'Set as default' button, then reopen this file again.

    2. Follow the step 1, if it is already check the above option, this issue maybe relates to the code you typed, access the .cpp or .h file in File Explorer and open with Notepad to check this files are corrupted or not, or includes any non-printing characters or not Unicode format.

    3. Go to Control Panel--Programs and Features, right click VS 2015 and choose Change-Repair to repair VS.

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 6, 2017 2:17 AM
    Moderator