lethe1337 2 / 2 / 0 Регистрация: 22.07.2020 Сообщений: 177 |
||||
1 |
||||
18.05.2022, 22:12. Показов 1213. Ответов 4 Метки си++ (Все метки)
В общем у меня есть задание: перенести программу с Си на С++. С плюсами знаком +- 2 часа, вот что слепил
При компиляции выдает следующие ошибки: Код 1>List.cpp 1>C:UsersFinsourcereposListListList.cpp(105,20): error C3861: Insert: идентификатор не найден 1>C:UsersFinsourcereposListListList.cpp(107,9): error C3861: Print: идентификатор не найден 1>C:UsersFinsourcereposListListList.cpp(108,9): error C3861: Inverse_sublist: идентификатор не найден 1>C:UsersFinsourcereposListListList.cpp(110,9): error C3861: Print: идентификатор не найден 1>C:UsersFinsourcereposListListList.cpp(119,20): error C3861: Append: идентификатор не найден 1>C:UsersFinsourcereposListListList.cpp(121,9): error C3861: Print: идентификатор не найден 1>C:UsersFinsourcereposListListList.cpp(122,9): error C3861: Inverse_sublist: идентификатор не найден 1>C:UsersFinsourcereposListListList.cpp(124,9): error C3861: Print: идентификатор не найден Помогите исправить =)
0 |
zss Модератор 13252 / 10391 / 6213 Регистрация: 18.12.2011 Сообщений: 27,793 |
||||
19.05.2022, 09:07 |
2 |
|||
Решение
1 |
2 / 2 / 0 Регистрация: 22.07.2020 Сообщений: 177 |
|
19.05.2022, 11:10 [ТС] |
3 |
zss, Вылезло это Код 1>List.obj : error LNK2005: "struct List __cdecl Append(struct List,int)" (?Append@@YA?AUList@@U1@H@Z) уже определен в Class.obj 1>List.obj : error LNK2005: "struct Node * __cdecl Create_node(int)" (?Create_node@@YAPEAUNode@@H@Z) уже определен в Class.obj 1>List.obj : error LNK2005: "int __cdecl Get_Value(struct List,int)" (?Get_Value@@YAHUList@@H@Z) уже определен в Class.obj 1>List.obj : error LNK2005: "struct Node * __cdecl Get_node(struct List const &,int)" (?Get_node@@YAPEAUNode@@AEBUList@@H@Z) уже определен в Class.obj 1>List.obj : error LNK2005: "struct List __cdecl Insert(struct List,int)" (?Insert@@YA?AUList@@U1@H@Z) уже определен в Class.obj 1>List.obj : error LNK2005: "void __cdecl Inverse_sublist(struct List,int,int)" (?Inverse_sublist@@YAXUList@@HH@Z) уже определен в Class.obj 1>List.obj : error LNK2005: "struct List __cdecl Pop_front(struct List)" (?Pop_front@@YA?AUList@@U1@@Z) уже определен в Class.obj 1>List.obj : error LNK2005: "void __cdecl Print(struct List)" (?Print@@YAXUList@@@Z) уже определен в Class.obj 1>List.obj : error LNK2005: "void __cdecl Swap(struct List,struct Node * const,struct Node * const)" (?Swap@@YAXUList@@QEAUNode@@1@Z) уже определен в Class.obj 1>C:UsersFinsourcereposListx64DebugList.exe : fatal error LNK1169: обнаружен многократно определенный символ - один или более 1>Сборка проекта "List.vcxproj" завершена с ошибкой. ========== Сборка: успешно: 0, сбой: 1, в актуальном состоянии: 0, пропущено: 0========== Добавлено через 4 минуты
0 |
lethe1337 2 / 2 / 0 Регистрация: 22.07.2020 Сообщений: 177 |
||||||||
19.05.2022, 21:14 [ТС] |
4 |
|||||||
zss, А можете объяснить, пожалуйста, в чем была ошибка? Добавлено через 24 минуты
Header.cpp
в List.cpp код тот же, что и после main(), но при компиляции вылазят те же ошибки, что и в прошлый раз: идентификатор не найден. Как это можно исправить?
0 |
zss Модератор 13252 / 10391 / 6213 Регистрация: 18.12.2011 Сообщений: 27,793 |
||||
20.05.2022, 06:17 |
5 |
|||
Решение
нужно реализовать через классы
Я не проверял правильность методов.
1 |
I have included stdio.h into my C++ project, why am I still getting this error? Also, after I added #include , printf(), in my code, was no longer underlined in red to suggest that there was any error.
Also, I would like to use the function, format(). Which library is that found in?
- c++
- printf
- stdio
asked Apr 27, 2015 at 3:50
RaisintoeRaisintoe
2011 gold badge3 silver badges11 bronze badges
4
-
«Which library is that found in?» — Boost? TinyFormat? cppformat? You tell us.
Apr 27, 2015 at 3:51
-
«I have included stdio.h into my C++ project, why am I still getting this error?» — please provide your compile command, your link command, and the exact error you are receiving. Do so by adding it to your question by clicking Edit (and don’t post it as a comment). Otherwise, there’s not enough information to help troubleshoot it.
Apr 27, 2015 at 3:54
-
«I would like to use the function, format()…» — that’s not a standard C library function. What did you have in mind? Are you using an external library? Do you have a reference to the function?
Apr 27, 2015 at 3:55
-
As with spelling in word processors, IDE underlining is just a hint that there could be something wrong. Underlining doesn’t definitely mean wrong, no underlining doesn’t definitely mean correct.
Apr 27, 2015 at 4:54
2 Answers
you must include stdio.h instead of cstdio.h
#include <stdio.h>
answered Apr 27, 2015 at 4:14
Use
#include< cstdio>
using namespace std;
after that you can use printf()
answered Apr 27, 2015 at 4:00
LoveToCodeLoveToCode
2962 silver badges18 bronze badges
1
- Remove From My Forums
-
Question
-
I think I already know the answer to this but I’ll ask the question anyway.
When I attempt to compile the following code:
#include <stdio.h>
#include <stdafx.h>
int count;
int main()
{
//Print the numbers 1 through 20
for (count = 1; count <= 20; count++)
printf(«%dn», count);
return 0;
}
I get the message: error C3861: ‘printf’: identifier not found
Does this message have to do with the changes made to Visual C++?
Am I missing something obvious?
Answers
-
Try this:
#include <stdafx.h>
#include <stdio.h>Or turn off precompiled headers. The gory details of this problem is that on a /Yu build (that is a build that use a PCH) the compiler ignores anything before the header file that marks the end of the PCH region. We are in the process of adding a warning for this situation — this new warning will show up in the next release of Visual C++.
Использую библиотеку math.h
и в ней для нахождения кубического корня есть функция cbrt();
Только вот при компиляции Visual Studio говорит: error C3861: cbrt: идентификатор не найден.
Мой код:
#include <stdio.h>
#include <cmath>
int main()
{
double PI = 3.1415926535897932384626433832795, x=0.25, y=1.31, a=3.5, b=0.9, P;
printf("Вы запустили программу для решения задачи 1 из лабораторной 1! n");
printf("Программа начинает расчет, ожидайте... n");
P=fabs((pow(sin(a*pow(x,3)+b*pow(y,2)-a*b),3))/(cbrt(pow((a*x*3+b*pow(y,2)-a),2)+PI)))+tan(a*pow(x,3)+b*pow(y,2)-a*b);
printf("Ответ для Задачи 1: %d n", P);
return 0;
}
Как решать проблему?
Я включил stdio.h в мой проект C ++, почему я все еще получаю эту ошибку? Кроме того, после того, как я добавил #include, printf () в моем коде больше не подчеркивался красным, чтобы предположить, что произошла какая-либо ошибка.
Также я бы хотел использовать функцию format (). В какой библиотеке это находится?
2
Решение
Вы должны включить stdio.h вместо cstdio.h
#include <stdio.h>
7
Другие решения
использование
#включают< cstdio>
использование пространства имен std;
после этого вы можете использовать printf ()
1