Error return statement with a value in function returning void fpermissive

Выдает такую ошибку. [Error] return-statement with a value, in function returning C++ Решение и ответ на вопрос 2259660

Black_Donut

0 / 0 / 0

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

Сообщений: 4

1

05.06.2018, 21:14. Показов 13054. Ответов 1

Метки нет (Все метки)


[Error] return-statement with a value, in function returning ‘void’ [-fpermissive]

Делаю программу для вычисления корня Методом Половинного деления. Решил разделить программу на главный файл(Main.cpp) и входной(In.cpp)|выходной(Out.cpp). In.cpp и Out.cpp подключены к Main.cpp через #include «». Я вызываю из In.cpp функцию VIBOR_1() и не могу ее вызвать ее из-за этой ошибки.

Компилятор ссылается на эту строчку. Указывает что ошибка здесь.

C++ (Qt)
1
else return i;
C++ (Qt)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void VIBOR_1()
{
    char c[3];
    int i;
    cout << "Выберите номер уравнения" << endl;
    while(1)
    {
        cout << "                   " << endl
             << endl;
        cin >> c;
        if((i=atoi(c))==0) 
        {
            cout << "Некорректный ввод. Повторите попытку" << endl
                 << endl;
        }
        else if((i=atoi(c))<=0 || (i=atoi(c))>3) 
        {
            cout << "Неверный ввод. повторите попытку" << endl
                 << endl;
        }
        else return i;
    }
    
}

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



hoggy

Эксперт С++

8719 / 4299 / 958

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

Сообщений: 9,744

06.06.2018, 00:11

2

Лучший ответ Сообщение было отмечено Black_Donut как решение

Решение

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

void VIBOR_1()

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

else return i;

ВИБАР_1 ни можит ничаго вэрнуть, дарагой!
дэлай так, да?

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int VIBOR_1()
{
    char c[3];
    int i;
    cout << "Выберите номер уравнения" << endl;
    while(1)
    {
        cout << "                   " << endl
             << endl;
        cin >> c;
        if((i=atoi(c))==0) 
        {
            cout << "Некорректный ввод. Повторите попытку" << endl
                 << endl;
        }
        else if((i=atoi(c))<=0 || (i=atoi(c))>3) 
        {
            cout << "Неверный ввод. повторите попытку" << endl
                 << endl;
        }
        else return i;
    }
    
}



0



Here’s the error (ignore the NumPy 1.7 deprecated warning before it):

[ 92%] Building CXX object thirdparty/opencv-ndarray-conversion/CMakeFiles/conversion.dir/conversion.cpp.o
In file included from /usr/include/numpy/ndarraytypes.h:1761:0,
                 from /usr/include/numpy/ndarrayobject.h:17,
                 from /home/sysadmin/Downloads/brisk/thirdparty/opencv-ndarray-conversion/conversion.h:8,
                 from /home/sysadmin/Downloads/brisk/thirdparty/opencv-ndarray-conversion/conversion.cpp:1:
/usr/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " 
  ^
In file included from /usr/include/sched.h:28:0,
                 from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/4.9/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/4.9/bits/gthr.h:148,
                 from /usr/include/c++/4.9/ext/atomicity.h:35,
                 from /usr/include/c++/4.9/bits/ios_base.h:39,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/istream:38,
                 from /usr/include/c++/4.9/sstream:38,
                 from /usr/include/c++/4.9/complex:45,
                 from /usr/local/include/opencv2/core/core.hpp:56,
                 from /usr/local/include/opencv2/imgproc/imgproc.hpp:46,
                 from /home/sysadmin/Downloads/brisk/thirdparty/opencv-ndarray-conversion/conversion.h:5,
                 from /home/sysadmin/Downloads/brisk/thirdparty/opencv-ndarray-conversion/conversion.cpp:1:
/home/sysadmin/Downloads/brisk/thirdparty/opencv-ndarray-conversion/conversion.cpp: In function ‘void init()’:
/home/sysadmin/Downloads/brisk/thirdparty/opencv-ndarray-conversion/conversion.cpp:9:5: error: return-statement with a value, in function returning 'void' [-fpermissive]
     import_array();
     ^
/home/sysadmin/Downloads/brisk/thirdparty/opencv-ndarray-conversion/conversion.cpp: In member function ‘void NDArrayConverter::init()’:
/home/sysadmin/Downloads/brisk/thirdparty/opencv-ndarray-conversion/conversion.cpp:125:5: error: return-statement with a value, in function returning 'void' [-fpermissive]
     import_array();
     ^
thirdparty/opencv-ndarray-conversion/CMakeFiles/conversion.dir/build.make:54: recipe for target 'thirdparty/opencv-ndarray-conversion/CMakeFiles/conversion.dir/conversion.cpp.o' failed
make[2]: *** [thirdparty/opencv-ndarray-conversion/CMakeFiles/conversion.dir/conversion.cpp.o] Error 1
CMakeFiles/Makefile2:233: recipe for target 'thirdparty/opencv-ndarray-conversion/CMakeFiles/conversion.dir/all' failed
make[1]: *** [thirdparty/opencv-ndarray-conversion/CMakeFiles/conversion.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

I am running Debian 8.5 with OpenCV 3.1.0 (built from GitHub) AND OpenCV 2.4.13 (also built from GitHub) on the same system, with python-numpy 1.8.2-2 (from Debian jessie APT repo). The NumPy warning probably could be handled by downgrading to NumPy 1.7, but I don’t have any idea what is causing the error in conversion.cpp.

Содержание

  1. С++ Как запустить программу?
  2. Задача
  3. Код программы:
  4. Ошибка №1
  5. Ошибка №2
  6. Ответы (1 шт):
  7. Compile error #19
  8. Comments
  9. Can’t open file in some situation,file path repeats #5166
  10. Comments
  11. Arduino.ru
  12. Регистрация новых пользователей и создание новых тем теперь только на новом форуме https://forum.arduino.ru
  13. forum.arduino.ru
  14. Как заставить return вернуть значение в функции?
  15. Error return statement with no value in function returning int fpermissive

С++ Как запустить программу?

Задача

Написать программу обработки файла, содержащего информацию о рейтинге студентов. Каждая запись должна содержать Ф.И.О. и полученный балл рейтинга. Вывести информацию, отсортированную в порядке увеличения рейтинга. Результаты выполнения программы сохранить в текстовом файле. При работе с файлом должны быть выполнены следующие действия: создание, просмотр, добавление новой записи, сортировка, сохранение результатов.

Код программы:

Ошибка №1

E:CProjects1main.cpp [Error] two or more data types in declaration of ‘main’ E:CProjects1Makefile.win recipe for target ‘main.o’ failed

Ругается вот на эту строку:

Ошибка №2

E:CProjects1main.cpp In function ‘int main()’:

E:CProjects1main.cpp [Error] return-statement with no value, in function returning ‘int’ [-fpermissive]

E:CProjects1main.cpp [Error] return-statement with no value, in function returning ‘int’ [-fpermissive]

E:CProjects1main.cpp [Error] return-statement with no value, in function returning ‘int’ [-fpermissive]

E:CProjects1Makefile.win recipe for target ‘main.o’ failed

Ругается на return

Ответы (1 шт):

Само собой — вы говорите примерно «а это моя левая правая рука».

В случае main , к счастью, выбора никакого нет — main возвращает int и только int .

Так что уберите из этой строки void .

Далее, второе аргумент — или char*argv[] , или char**argv , но не ваш вариант. Выберите что-то одно.

Потом — все return в функции main обязаны возвращать значения. Какие — ваше дело. Обычно это код ошибки; если выход штатный и ошибок нет — return 0 .

Потом, забудьте про функцию gets ! Считайте, что ее нет в стандарте (а ее по большому счету там и нет. ) fgets из stdin или gets_s , но не gets !

Если будет ругань из-за переменной size — VC++ 2017 ругается — то укажите в тексте явно, что вы обращаетесь к глобальной переменной, написав вместо size — ::size .

Источник

Compile error #19

While compiling I get the following error:

The text was updated successfully, but these errors were encountered:

It is associated with these changes

See the commented out
SET(VERSION_MAJOR «1»)
SET(VERSION_MINOR «2»)

These have moved to a new file. VERSION.cmake

Can you adapt the linux section for that? get it working and make a PR to Sean?
I would like to add those changes too.

@rgleason
I tried but could not. I found about «VERSION.cmake» but I could not find where it is included.

For a test, In «rtlsdr_pi.cpp» I forced the version (return 1 and return 3). I could compile without error but then Opencpn would not recognize the PI. Got the error:
11:16:42 EST: Erreur : /usr/lib/opencpn/librtlsdr_pi.so: undefined symbol: _Z15VHFFrequencyMHZib
Sorry, I am not fluent enough in all this.

Ok, I think I need to add .travis file and perhaps edit some cmake.

rtlsdr_pi.cpp line 194 and 197

«could not find where it is included.»
This may be the problem. The time I ran removed the # comment out and it worked.
SET(VERSION_MAJOR «1»)
SET(VERSION_MINOR «2»)
but I don’t think it was right. I get the error too now. I believe it is from Sean’s «Update Build»
a line is missing.

Think I found it
Line 19 cmakelists.txt
Will try it and then make a PR

I tried it.
Same error.

Yes, I’ve done some more but reached a point that I think Sean should look at it as I don’t want to mess up his QT, Android, etc setup and he is clearly working towards resolving all this to it compiles for everything.

I am going to make a PR of the changes I’ve made so far so Sean can review or accept and then resolve the ENDIF

Источник

Can’t open file in some situation,file path repeats #5166

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10 1809
  • VS Code Version: 1.43.1
  • C/C++ Extension Version: 0.26.3
  • Other extensions you installed (and if the issue persists after disabling them):C/C++ IntelliSense,C/C++ Compile Run
  • Does this issue involve using SSH remote to run the extension on a remote machine?: I don’t have remote machine, what should I do
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).
    In a workspace with only one .cpp file and auto configured .vscode folder, and only one extension enabled.

Steps to reproduce

  1. Make some mistake in code
  2. Compile
  3. Show Errors
  4. Click on the problem
  5. In some situation, unable to open cpp, and file path repeats

Expected behavior

open the cpp on click

Logs

Screenshots





Additional context

The text was updated successfully, but these errors were encountered:

Источник

Arduino.ru

Регистрация новых пользователей и создание новых тем теперь только на новом форуме https://forum.arduino.ru

forum.arduino.ru

Как заставить return вернуть значение в функции?

Имеется скетч с функцией printDateTime():

Ошибка: return-statement with a value, in function returning ‘void’ [-fpermissive]

Однако после смены void на char, ошибка компиляции стала следующей:

invalid conversion from ‘char*’ to ‘char’ [-fpermissive]

Что опять не так 🙁

Почитай этюды про память. Здесь, вшапке

Grove — у вас опыт, видимо, нулевой? Много обьяснять придется.

Лучше бы вы почитали какую-нить толстую книжку про Си — про символы, символьные массивы, переменные и ссылки на них. Про передачу парметров по значению и по ссылке, область видимости, инициализацию и очистку переменных. это далеко не полный список того, что нужно знать. чтобы правильно передать ваши данные из процедуры в основную программу. Пока вы их передаете в корне неверно.

И не надейтесь получить готовый ответ. Даже если кто-то напишет, как правильно передать время из функции — все равно уже на следующей строчке кода вы опять споткнетесь о что-то другое. И так будет постоянно, если нет базовых знаний.

Источник

Error return statement with no value in function returning int fpermissive

This coding was not function because of the return cutPoint. please help me to solve this problem

#include
using namespace std;

void quickSort (int*,int,int);
int partition(int*, int,int);
int main()
<
int a[12];
for(int i=0;i >a[i];
>

Please always use code tags. And ensure the code has some indentation.

Without this, it is hard to see what is happening.

You have a couple of very simple mistakes in your code:

1. Remove the ; from your partition function definition.

2. Remove the last > and move it to the end of your quicksort function.

And as TheIdeaMan suggested PLEASE use code tags so your source is easier to read:

I noticed that if you enter two or more numbers that are the same your program logic goes into what appears to be an infinite loop. Enter different numbers and your quicksort works without «hanging.»

I didn’t do any debugging so I can’t say with any definite idea where your logic is faulty. Just a gut impression you are not properly checking when two numbers are equal and thereby skipping the actual sorting of the two elements.

Источник

Понравилась статья? Поделить с друзьями:
  • Error retrieving network interface
  • Error retrieving information from server df dferh 01 что делать
  • Error retrieving database metadata
  • Error retrieving data перевод
  • Error required files are missing