Ошибка идентификатор cout не определен

5 / 1 / 4

Регистрация: 03.03.2013

Сообщений: 229

1

23.01.2014, 18:40. Показов 24561. Ответов 19


Студворк — интернет-сервис помощи студентам

Добрый вечер, пишу первую программу на C++, пишу в VS Express 2013, ошибка сборки: идентификатор cout не определен. Возможно дело в том, что учусь по старой книге, исправьте пожалуйста ошибку и объясните. Скриншот прилагается.

Миниатюры

Первая программа в VS, идентификатор cout не определен
 



0



Baronnn

0 / 0 / 0

Регистрация: 16.01.2014

Сообщений: 6

23.01.2014, 18:41

2

После

C++
1
using namespace System

добавить

C++
1
using std;



0



cooller

571 / 539 / 280

Регистрация: 25.12.2013

Сообщений: 1,456

23.01.2014, 18:46

3

Baronnn,

C++
1
2
#include<iostream>
using namespace std;

Либо

C++
1
std::cout<<...



1



xxgurman

5 / 1 / 4

Регистрация: 03.03.2013

Сообщений: 229

23.01.2014, 18:48

 [ТС]

4

Цитата
Сообщение от Baronnn
Посмотреть сообщение

После

C++
1
using namespace System

После? У меня ведь нет такой строчки. Добавил после #include <iostream.h> то что Вы написали, безрезультатно.

Миниатюры

Первая программа в VS, идентификатор cout не определен
 



0



Baronnn

0 / 0 / 0

Регистрация: 16.01.2014

Сообщений: 6

23.01.2014, 18:50

5

cooller_94, правильно)) ошибся

добавить

C++
1
using namespace std;

или отдельно

C++
1
2
3
using std::cin;
using std::cout;
using std::endl;

и т.д.



0



xxgurman

5 / 1 / 4

Регистрация: 03.03.2013

Сообщений: 229

23.01.2014, 18:57

 [ТС]

6

Цитата
Сообщение от Baronnn
Посмотреть сообщение

cooller_94, правильно)) ошибся

добавить

C++
1
using namespace std;

или отдельно

C++
1
2
3
using std::cin;
using std::cout;
using std::endl;

и т.д.

Следующая ошибка! Возможно вы забыли добавить директиву «include «stdafx.h»» в источник.

Миниатюры

Первая программа в VS, идентификатор cout не определен
 



0



Ev_Hyper

Заблокирован

23.01.2014, 19:02

7

Цитата
Сообщение от xxgurman
Посмотреть сообщение

Возможно вы забыли добавить директиву «include «stdafx.h»» в источник.

добавьте её или пересоздайте проект убрав галочки напротив «зарание скомп. заголовок».



0



5 / 1 / 4

Регистрация: 03.03.2013

Сообщений: 229

23.01.2014, 19:05

 [ТС]

8

Цитата
Сообщение от Ev_Hyper
Посмотреть сообщение

добавьте её или пересоздайте проект убрав галочки напротив «зарание скомп. заголовок».

Следующая ошибка: Отсутствует спецификатор типа — предполагается int. C++ не поддерживает int по умолчанию

Миниатюры

Первая программа в VS, идентификатор cout не определен
 



0



3254 / 2056 / 351

Регистрация: 24.11.2012

Сообщений: 4,909

23.01.2014, 19:06

9

int main()

И возьмите другую книгу…



0



5 / 1 / 4

Регистрация: 03.03.2013

Сообщений: 229

23.01.2014, 19:28

 [ТС]

10

Цитата
Сообщение от 0x10
Посмотреть сообщение

int main()

И возьмите другую книгу…

Не подскажете куда добавить int main()? Добавил интуитивно вот сюда, все тщетно

Миниатюры

Первая программа в VS, идентификатор cout не определен
 



0



0x10

3254 / 2056 / 351

Регистрация: 24.11.2012

Сообщений: 4,909

23.01.2014, 19:30

11

Во-первых, вставляйте исходники текстом.
Во-вторых, по-русски внизу написано, что у функци main уже есть тело.

C++
1
2
3
4
int main() {
    std::cout << // .. и т д
    return 0;
}



1



cooller

571 / 539 / 280

Регистрация: 25.12.2013

Сообщений: 1,456

23.01.2014, 19:30

12

xxgurman, Добавь в самом начале

C++
1
#include "stdafx.h"

запоздал



1



0 / 0 / 0

Регистрация: 16.01.2014

Сообщений: 6

23.01.2014, 19:31

13

Есть же функция main() … Вместо него int main()



0



Неэпический

17819 / 10592 / 2044

Регистрация: 27.09.2012

Сообщений: 26,636

Записей в блоге: 1

23.01.2014, 19:32

14

Цитата
Сообщение от xxgurman
Посмотреть сообщение

Возможно вы забыли добавить директиву «include «stdafx.h»» в источник.

https://www.cyberforum.ru/blog… g1905.html



0



xxgurman

5 / 1 / 4

Регистрация: 03.03.2013

Сообщений: 229

23.01.2014, 19:39

 [ТС]

15

Цитата
Сообщение от 0x10
Посмотреть сообщение

Во-первых, вставляйте исходники текстом.
Во-вторых, по-русски внизу написано, что у функци main уже есть тело.

C++
1
2
3
4
int main() {
    std::cout << // .. и т д
    return 0;
}

Спасибо Вам, и всем отвечающим, все получилось. Как же мне теперь запустить мою программу/увидеть что выводится на экран? Был создан файл ConsoleApplication3.exe но при открытии он мне ничего не показывает, открывается и закрывается сразу же.



0



3254 / 2056 / 351

Регистрация: 24.11.2012

Сообщений: 4,909

23.01.2014, 19:43

16

Цитата
Сообщение от xxgurman
Посмотреть сообщение

открывается и закрывается сразу же.

См ссылку от Croessmah



0



5 / 1 / 4

Регистрация: 03.03.2013

Сообщений: 229

23.01.2014, 19:52

 [ТС]

17

Цитата
Сообщение от 0x10
Посмотреть сообщение

См ссылку от Croessmah

Извините, вы переходили по этой ссылке? Разрешение скринов настолько мало, что текст не читаем, предложите пожалуйста альтернативу.

Добавлено через 4 минуты

Цитата
Сообщение от 0x10
Посмотреть сообщение

См ссылку от Croessmah

Быть может нужно добавить что то, чтобы программа закрывалась только при нажатии на клавишу, из «опыта» в Pascal.



0



3254 / 2056 / 351

Регистрация: 24.11.2012

Сообщений: 4,909

23.01.2014, 19:53

18

Перед return воткнуть system(«pause») или getchar() или запускать без отладчика.



1



5 / 1 / 4

Регистрация: 03.03.2013

Сообщений: 229

23.01.2014, 19:55

 [ТС]

19

Цитата
Сообщение от 0x10
Посмотреть сообщение

Перед return воткнуть system(«pause») или getchar() или запускать без отладчика.

Вы были правы, я был не внимателен. Спасибо большое.



0



Неэпический

17819 / 10592 / 2044

Регистрация: 27.09.2012

Сообщений: 26,636

Записей в блоге: 1

23.01.2014, 19:58

20



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

23.01.2014, 19:58

Помогаю со студенческими работами здесь

Требуется идентификатор (идентификатор с не определён)
Не могу понять в чём ошибка данного записи.Пожалуйста, объясните!!!
vector &lt;pair&lt;int, int&gt;&gt; STACK;…

Почему компилятор Visual studio 2017 пишет, что идентификатор gets не определен, что можно сделать? Программа ищет слова
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt;
#include &lt;string.h&gt;
#include &lt;ctype.h&gt;

#define MAX 5…

Идентификатор не определен
void __fastcall String(int x, int y, DWORD Color, DWORD Style, const char *Format, …)
{

Идентификатор не определен
Писали ее на microsoft visual studio2013. выдает 7 ошибок на 74, 125, 136, 149, 159, 170 и 177 и…

Идентификатор не определён
#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;
#include &lt;fstream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;…

Идентификатор gets не определен
Собственно,в этом весь вопрос:)

#include &lt;iostream&gt;
#include &lt;cstring&gt;
#include &lt;cstdio&gt;…

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:

20

I learn C++ and COM through the books.
In the IDE MS Visual Studio 2012 I have created new empty C++ project, and added some existing files to it. My CPP file contains #include<iostream> row, but in editor I got such messages:

Error: identifier «cout» is undefined

end

Error: identifier «endl» is undefined

Code:

#include<iostream>
#include"interfaces.h" // unknown.h, objbase.h, initguid.h

class CA {//: public IX, IY{
public:
    // Constructor
    CA();
    // Destructor
    ~CA();
    // IUnknown
    virtual HRESULT __stdcall QueryInterface(const IID& iid, void** ppv);
    virtual ULONG __stdcall AddRef();
    virtual ULONG __stdcall Release();
    // IX
    virtual void __stdcall Fx1();
    virtual void __stdcall Fx2();
    // IY
    virtual void __stdcall Fy1(){ cout << "Fy1" << endl; }  // errors here
    virtual void __stdcall Fy2(){ cout << "Fy2" << endl; }  // errors here also
private:
    long counter;
};

Why it happens?

JaMiT's user avatar

JaMiT

14.1k4 gold badges15 silver badges31 bronze badges

asked Nov 3, 2012 at 11:03

Andrey Bushman's user avatar

Andrey BushmanAndrey Bushman

11.7k17 gold badges85 silver badges180 bronze badges

2

You need to specify the std:: namespace:

std::cout << .... << std::endl;;

Alternatively, you can use a using directive:

using std::cout;
using std::endl;

cout << .... << endl;

I should add that you should avoid these using directives in headers, since code including these will also have the symbols brought into the global namespace. Restrict using directives to small scopes, for example

#include <iostream>

inline void foo()
{
  using std::cout;
  using std::endl;
  cout << "Hello world" << endl;
}

Here, the using directive only applies to the scope of foo().

answered Nov 3, 2012 at 11:04

juanchopanza's user avatar

juanchopanzajuanchopanza

223k34 gold badges399 silver badges479 bronze badges

1

You can add this at the beginning after #include <iostream>:

using namespace std;

Tom Fenech's user avatar

Tom Fenech

71.9k12 gold badges107 silver badges140 bronze badges

answered Feb 25, 2014 at 16:03

arash's user avatar

cout is in std namespace, you shall use std::cout in your code.
And you shall not add using namespace std; in your header file, it’s bad to mix your code with std namespace, especially don’t add it in header file.

answered Nov 3, 2012 at 11:04

billz's user avatar

billzbillz

44.5k9 gold badges83 silver badges100 bronze badges

1

The problem is the std namespace you are missing. cout is in the std namespace.
Add using namespace std; after the #include

answered Aug 21, 2020 at 16:17

Abdellah Ramadan's user avatar

If you have included #include iostream and using namespace std; it should work. If it still doesn’t work, make sure to check that you haven’t deleted anything in the iostream file. To get to you iostream file, just Ctrl +Click your #include iostream and it should take you to that file. You can paste the below original iostream file to your iostream file and it should work.

// Standard iostream objects -*- C++ -*-

// Copyright (C) 1997-2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file include/iostream
 *  This is a Standard C++ Library header.
 */

//
// ISO C++ 14882: 27.3  Standard iostream objects
//

#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1

#pragma GCC system_header

#include <bits/c++config.h>
#include <ostream>
#include <istream>

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

  /**
   *  @name Standard Stream Objects
   *
   *  The &lt;iostream&gt; header declares the eight <em>standard stream
   *  objects</em>.  For other declarations, see
   *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html
   *  and the @link iosfwd I/O forward declarations @endlink
   *
   *  They are required by default to cooperate with the global C
   *  library's @c FILE streams, and to be available during program
   *  startup and termination. For more information, see the section of the
   *  manual linked to above.
  */
  //@{
  extern istream cin;       /// Linked to standard input
  extern ostream cout;      /// Linked to standard output
  extern ostream cerr;      /// Linked to standard error (unbuffered)
  extern ostream clog;      /// Linked to standard error (buffered)

#ifdef _GLIBCXX_USE_WCHAR_T
  extern wistream wcin;     /// Linked to standard input
  extern wostream wcout;    /// Linked to standard output
  extern wostream wcerr;    /// Linked to standard error (unbuffered)
  extern wostream wclog;    /// Linked to standard error (buffered)
#endif
  //@}

  // For construction of filebuffers for cout, cin, cerr, clog et. al.
  static ios_base::Init __ioinit;

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

#endif /* _GLIBCXX_IOSTREAM */

answered Oct 31, 2021 at 13:30

Yaakov Brill's user avatar

You Check your C++ version or You must write this statement to global scope
using namespace std;

answered May 16 at 7:23

Ganesh Pawar's user avatar

1

you have to use:using namespace std
or else
you have to write using std::endl ie import only endl from std library.

answered Feb 5 at 14:01

Naveen Kamath's user avatar

1

I ran across this error after just having installed vs 2010 and just trying to get a nearly identical program to work.

I’ve done vanilla C coding on unix-style boxes before, decided I’d play with this a bit myself.

The first program I tried was:

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
    cout << "Hello World!";
    return 0;
}

The big thing to notice here… if you’ve EVER done any C coding,

int _tmain(int argc, _TCHAR* argv[])

Looks weird. it should be:

int main( int argc, char ** argv )

In my case I just changed the program to:

#include <iostream>
using namespace std;

int main()
{
     cout << "Hello world from  VS 2010!n";
     return 0;
}

And it worked fine.

Note: Use CTRL + F5 so that the console window sticks around so you can see the results.

If you are new to c++ programming language then possibly you will come across c++ identifier is undefined errors. You might get identifier is undefined error in multiple ways, below 4 different possible errors for identifier is undefined in c++.

identifier is undefined
identifier is undefined error

Possible different errors:

  1. c++ identifier is undefined
  2. c++ identifier cout is undefined
  3. c++ identifier string is undefined
  4. identifier system is undefined c++

Solution-1 : identifier is undefined due to variable/function is not declared

#include <iostream>
using namespace std;

void func(int a) {
	cout << a;
}

int main()
{
	int Value1;
	Value1 = 10;

	func(Value); 
	// error C2065: 'Value': undeclared identifier
    // Solution: func(Value1); 

	return 0;
}

Here we have not declared Value variable. So it is giving undeclared error. If we change it to func(Value1); then error will be resolve. Always check that particular variable is declared or not.

identifier is undefined due to variable / function not declared

identifier is undefined due to variable / function not declared
#include <iostream>
using namespace std;

int main()
{
	int Value1;
	Value1 = 10;

	func(Value1);
	// error C3861: 'func': identifier not found

	return 0;
}

Here func(int value){…} is not available so it will give error for c++ identifier not found.

Solution-2 : c++ identifier is undefined due to variable is out of Scope {..}

#include <iostream>
using namespace std;

int main()
{
	{
	 int Value1; // Variable scope will be over after {}
	}

	Value1 = 10;
    // error C2065: 'Value1': undeclared identifier

	return 0;
}

Here variable declaration scope is over once {..} is over. So outside scope if we try to access variable then it will give error for c++ identifier is undefined.

2) c++ identifier cout is undefined

#include <iostream>
int main()
{
	int Value1;
	Value1 = 10;

	cout << Value1;
	// error C2065: 'cout': undeclared identifier

	return 0;
}
identifier undefined resolve by namespace std
identifier undefined resolve by namespace std

Here error is coming because cout is inside std namespace.

If you don’t wand to add std::cout every time then you can add using namespace std; in header section so it will apply to whole file.

#include <iostream>
using namespace std; // Need to add it

Using these both solutions you can easily remove c++ identifier cout is undefined error from your program.

3) c++ identifier string is undefined

#include <iostream>
int main()
{
	string str;
	// C2065: 'string': undeclared identifier
	return 0;
}

string variable is also inside std namespace, so you will need to use std::string every time or you can add using namespace std; inside starting of file includes.

std::string str;
OR
using namespace std; 

Using this code change you can resolve c++ identifier string is undefined from your program.

4) identifier system is undefined c++

#include <stdio.h>
int main()
{
	system("pause");
	// error C3861: 'system': identifier not found
	// system is available inside #include <stdlib.h>
	return 0;
}
identifier system is undefined c++
identifier system is undefined c++

system() is define inside #include <stdlib.h> header file. If you have not included this file then you will get errors for identifier system is undefined c++.

Conclusion: c++ identifier is undefined

Whenever you are getting identifier is undefined error in c++ then you need to check 1) Variable name is declared or not 2) Variable or function is not out of scope 3) Proper #include file is added or not. Mostly due to these three reason error occurs. By checking coding you will able to identify issue.

See more:

C++ is widely used programming language, you can read more use of c++ in real world.

Reader Interactions

Я работаю над частью «драйвера» моего назначения программирования, и я продолжаю получать эту абсурдную ошибку:

ошибка C2065: ‘cout’: необъявленный идентификатор

Я даже пытался использовать std:: cout, но я получаю еще одну ошибку, которая говорит: IntelliSense: пространство имен «std» не имеет члена «cout» , когда у меня есть объявленный с использованием пространства имен std, включая iostream +, я даже пытался использовать ostream

Я знаю, что это стандартный вопрос о нобе, но это меня насторожило, и я новичок (это означает: я запрограммировал раньше…)

#include <iostream>
using namespace std;

int main () {
    cout << "hey" << endl;
 return 0;
}

Я использую Visual Studio 2010 и запускаю Windows 7. Все файлы .h имеют «использование пространства имен std» и включают iostream и ostream.

Ответ 1

В Visual Studio вы должны #include "stdafx.h" и быть первым включением файла cpp. Например:

Это не будет работать.

#include <iostream>
using namespace std;
int main () {
    cout << "hey" << endl;
    return 0;
}




#include <iostream>
#include "stdafx.h"
using namespace std;
int main () {
    cout << "hey" << endl;
    return 0;
}

Это подойдет.

#include "stdafx.h"
#include <iostream>
using namespace std;
int main () {
    cout << "hey" << endl;
    return 0;
}

Вот отличный ответ о том, что делает заголовок stdafx.h.

Ответ 2

напишите этот код, он отлично работает.

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
 cout<<"Hello World!";
  return 0;
}

Ответ 3

У меня была такая же проблема на Visual Studio С++ 2010. Это легко исправить. Над функцией main() просто замените стандартные строки с этим ниже, но с символом фунта перед включенными.

# include "stdafx.h"
# include <iostream>
using  namespace std;

Ответ 4

include "stdafx.h" в порядке

Но вы не можете использовать cout, если вы не включили using namespace std

Если вы не включили пространство имен std, вам нужно написать std::cout вместо простого cout

Ответ 5

Я видел, что если вы используете

#include <iostream.h>

тогда вы получите эту проблему.

Если вы используете

#include <iostream>  

(уведомление — без .h)

то вы не получите проблему, о которой вы упомянули.

Ответ 6

Если вы начали проект, требующий строки #include "stdafx.h", поставьте его первым.

Ответ 7

Нижеприведенный код компилируется и запускается правильно для меня, используя gcc. Попробуйте скопировать/вставить это и посмотреть, работает ли он.

#include <iostream>
using namespace std;

int bob (int a) { cout << "hey" << endl; return 0; };

int main () {
    int a = 1;
    bob(a);
    return 0;
}

Ответ 8

Если единственным файлом, который вы включаете, является iostream, и он все еще говорит undefined, то, возможно, iostream не содержит того, что он должен был. Возможно ли, что у вас есть пустой файл, совпадающий по имени «iostream» в вашем проекте?

Ответ 9

Я видел похожие вещи, когда я использовал расширение .c файла с кодом С++. Кроме этого, я должен согласиться со всеми о багги установке. Это работает, если вы попытаетесь скомпилировать проект с более ранней версией VS? Попробуйте VС++ Express 2008. Его бесплатно на msdn.

Ответ 10

Такое глупое решение в моем случае:

// Example a
#include <iostream>    
#include "stdafx.h"

Выше было указано в качестве примера a, когда я изменил его, чтобы он был похож на пример b ниже…

// Example b
#include "stdafx.h"
#include <iostream>  

Мой код составлен как шарм. Попробуйте, гарантированно сработает.

Ответ 11

прежде чем вы начнете эту программу, избавитесь от всего кода и сделайте простой мир привет внутри основного. Включать только iostream и использовать пространство имен std;.
Постепенно добавьте его, чтобы найти свою проблему.

cout << "hi" << endl;

Ответ 12

У меня есть VS2010, Beta 1 и Beta 2 (один на моей рабочей машине и один на дому), и я использовал std множество без проблем. Попробуйте ввести:

std::

И посмотрите, дает ли Intellisense что-нибудь. Если это дает вам обычный материал (abort, abs, acos и т.д.), За исключением cout, ну тогда это довольно головоломка. Определенно посмотрите на ваши заголовки С++ в этом случае.

Помимо этого, я бы просто добавил, чтобы убедиться, что вы используете обычный пустой проект (не CLR, где Intellisense поврежден), и что вы на самом деле пытались построить проект хотя бы один раз. Как я уже упоминал в комментарии, VS2010 анализирует файлы после добавления include; возможно, что что-то застряло в парсере, и он не сразу «нашел» cout. (В этом случае попробуйте перезапустить VS, возможно?)

Ответ 13

У меня была такая же проблема при запуске проекта ms С++ 2010 с нуля — я удалил все файлы заголовков, сгенерированные с помощью ms, но использовал:

#include "stdafx.h"
#include <iostream>
using namespace std;

int main() {
   cout << "hey" << endl;
   return 0;
}

Мне пришлось включить stdafx.h, поскольку это вызвало ошибку, в которой он не был.

Ответ 14

Возьмите код

#include <iostream>
using namespace std;

из вашего .cpp файла, создайте файл заголовка и поместите его в файл .h. Затем добавьте

#include "whatever your header file is named.h"

в верхней части вашего .cpp-кода. Затем запустите его снова.

Ответ 15

Вы уверены, что он компилируется как С++? Проверьте имя файла (он должен заканчиваться на .cpp). Проверьте настройки проекта.

Нет ничего плохого в вашей программе, а cout находится в namespace std. Ваша установка VS 2010 Beta 2 является дефектной, и я не думаю, что это просто ваша установка.

Я не думаю, что VS 2010 готов к С++. Стандартная программа «Hello, World» не работала на бета-версии 1. Я просто попытался создать тестовое консольное приложение Win32, а сгенерированный файл test.cpp не имел функции main().

У меня действительно очень плохое чувство о VS 2010.

Ответ 16

Попробуй, это сработает. Я проверил его в Windows XP, Visual Studio 2010 Express.

#include "stdafx.h"
#include <iostream>
using namespace std;

void main( ) 
{
   int i = 0;
   cout << "Enter a number: ";
   cin >> i;
}

Ответ 17

Когда вы создали свой проект, вы не установили правильно использовать предварительно скомпилированные заголовки. Измените его в свойствах → C/С++ → предварительно скомпилированные заголовки.

Ответ 18

В Visual Studio используйте весь ваш фильтр заголовка ниже «stdafx.h».

Ответ 19

Включите библиотеку std, вставив следующую строку вверху вашего кода:

using namespace std;

Ответ 20

обычно сохраняется в папке C:Program FilesMicrosoft Visual Studio 8VCinclude. Сначала проверьте, все ли он там. Затем выберите «Инструменты + варианты», «Проекты и решения», «Каталоги VС++», выберите «Включить файлы» в поле «Показать каталоги для» и дважды проверьте, что включение (VCInstallDir) включено в список.

Ответ 21

Я столкнулся с этой ошибкой после того, как установил vs 2010 и просто пытался получить почти идентичную программу для работы.

Я уже делал кодировку ваниль C в коробках в стиле unix, решил, что немного поиграю с этим.

Первая программа, которую я пробовал, была:

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
    cout << "Hello World!";
    return 0;
}

Большая вещь, чтобы заметить здесь… если вы все сделали C-кодирование,

int _tmain(int argc, _TCHAR* argv[])

Выглядит странно. это должно быть:

int main( int argc, char ** argv )

В моем случае я просто изменил программу на:

#include <iostream>
using namespace std;

int main()
{
     cout << "Hello world from  VS 2010!n";
     return 0;
}

И он отлично работал.

Примечание. Используйте CTRL + F5, чтобы окно консоли закрывалось, чтобы вы могли видеть результаты.

Ответ 22

Просто используйте printf!

Включите stdio.h в заголовочный файл stdafx.h для printf.

Ответ 23

Я пришел сюда, потому что у меня была такая же проблема, но когда я сделал #include "stdafx.h", он сказал, что не нашел этот файл.
Что для меня было трюком: #include <algorithm>.
Я использую Microsoft Visual Studio 2008.
Это то, что вы можете использовать тогда, в том числе. ‘count’: Ссылка

Ответ 24


Это был компилятор — теперь я использую Eclipse Galileo, и программа работает как чудо


  • Ошибка идеального незнакомца дорама скачать торрент
  • Ошибка идеального незнакомца дорама 2012
  • Ошибка идеального незнакомца cuo dian yuan yang
  • Ошибка игрока теория игр
  • Ошибка игрока теория вероятности