Home c++ cannot open source file “stdafx.h”

cannot open source file “stdafx.h”

Author

Date

Category

here is the program code, the task is to shift the number bit by bit to the right

#include "stdafx.h"
  #include & lt; stdio.h & gt;
  #include & lt; conio.h & gt;
  #include & lt; locale.h & gt;
  #include & lt; iostream & gt;
  using namespace std;
  int main (void)
  {
    setlocale (LC_ALL, "");
    int i, j;
    short x, check = 1, saver3 = -32768;
    cout & lt; & lt; ("Enter the number of shifts \ n");
    cin & gt; & gt; j;
    cout & lt; & lt; ("Please enter a number \ n");
    cin & gt; & gt; x;
    cout & lt; & lt; ("The original number in the binary system \ n");
    for (i = 15; i & gt; = 0; i--)
    {
      if (x & amp; (check & lt; & lt; i)) {cout & lt; & lt; 1; }
      else {cout & lt; & lt; 0; }
    }
    for (i = 0; i & lt; j; i ++)
    {
      if (x & lt; 0)
      {
        if (x & amp; check) {x = x & gt; & gt; 1; }
        else {x = x & gt; & gt; 1; x = x + saver3; }
      }
      else if (x & gt; 0)
      {
        if (x & amp; check) {x = x & gt; & gt; 1; x = x + saver3; }
        else {x = x & gt; & gt; 1; }
      }
    }
    cout & lt; & lt; endl & lt; & lt; ("Received number \ n");
    cout & lt; & lt; dec & lt; & lt; x;
    cout & lt; & lt; endl & lt; & lt; ("The resulting number in the binary system \ n");
    for (i = 15; i & gt; = 0; i--)
    {
      if (x & amp; (check & lt; & lt; i)) {cout & lt; & lt; 1; }
      else {cout & lt; & lt; 0; }
    }
    _getch ();
  }

Answer 1

The answer is given in the comment by HolyBlackCat user, since I have VC++ 17, I had to change #include "stdafx.h" to #include "pch.h" .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions