如何在调试中通过传递引用开始
How to start by pass reference in debug
哼伙计们,在这个程序中,我希望用户设置凸轮录制帧速率和所需的项目帧速率以获得实际帧速率。我知道这听起来很荒谬,对不起(,所以我通过传递引用使用。程序构建成功,但当我手动调试时,void get 数据没有启动。怎么会发生这种情况以及如何解决这个问题?它在第 123 行,我无法进一步调试
#include<iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <string.h>
using namespace std;
void manualMode();
void defaultMode();
void Getdata(double& camrecord, double& projectfps);
void calculate(double& camrecord, double& projectfps, double& actual);
void Displayactualframerate(double& out);
int speed, timeTofly, operation;
int angle = 90;
int main() {
int mode = 0, part = 3;
double flyLevel;
int obstacleSensor = 0, timer = 3, AccelerometerSensor = 0, tempSensor = 25;
char startPause;
cout << "Drone Flying Technology" << endl;
do {
cout << "Choose Mode: (1)Default, (2)Manual n";
cin >> mode;
if (mode == 1)
defaultMode();
if (mode == 2)
manualMode();
} while (mode == 0);
cout << "Choose how to fly: (1)Upper , (2)Lower , (3)Upper and Lower n";
cin >> part;
switch (part) {
case 1:
case 2:
flyLevel = 0.5;
break;
case 3:
flyLevel = 1;
break;
}
if (obstacleSensor == 0) {
do {
cout << "Press (S) to Start,and swing the propeller." << endl;
cin >> startPause;
cout << "LED is Onn";
while (AccelerometerSensor != flyLevel) {
AccelerometerSensor++;
}
cout << "Flying session Started! Time Left:" << timeTofly << endl;
cout << "Eagle eye Operation Started!n";
timeTofly = timeTofly / 2;
cout << "Crusing mode initiate Time Left:" << timeTofly << endl;
timeTofly = timeTofly / 2;
cout << "Free fly commenced Time Left:" << timeTofly << endl;
timeTofly = 0;
startPause = 'P';
} while ((startPause == 's') || (startPause == 'S'));
}
cout << "End!nLED is Off";
return 0;
}
void manualMode() {
cout << "Enter drone speed (knot) n";
cin >> speed;
cout << "Enter Time to fly: n";
cin >> timeTofly;
cout << "Choose Operation: (1)Fully manual, (2)Normal Orientation, (3)Free orientation, (4)FPV racing, (5)Alln";
cin >> operation;
}
void defaultMode() {
int howtofly;
cout << "how to fly: (1)Circle, (2)Altitude Hold, (3)Free orientationn";
cin >> howtofly;
switch (howtofly) {
case 1:
speed = 30;
timeTofly = 3;
break;
case 2:
speed = 40;
timeTofly = 3;
break;
case 3:
speed = 60;
timeTofly = 3;
break;
}
char name[25];
char id[5];
float m1, m2, m3, m4, m5;
ofstream outputFile("droneinfo.txt", ios::out);
cout << "Please enter object you want to record,drone id imei number and your 5 preferred video fps:n";
cout << "nPress <ctrl> + z to stop. n";
while (cin >> id >> name >> m1 >> m2 >> m3 >> m4 >> m5)
{
outputFile << id << " " << name << " " << m1 << " " << m2 << " " << m3 << " " << m4 << " " << m5;
}
double camrecord;
double projectfps;
double actual, out;
Getdata(camrecord, projectfps);
calculate(camrecord, projectfps, actual);
Displayactualframerate(actual);
}
void Getdata(double& camrecord, double& projectfps) {
cin >> camrecord;
cin >> projectfps;
cout << "Please enter cam recording =" << camrecord << "f/s ,nDesired footage frame rate="
<< projectfps<<"f/s";
}
//-------------------//
void calculate(double& camrecord, double& projectfps, double& actual) {
actual = (camrecord / projectfps);
}
//-------------------//
void Displayactualframerate(double& out) {
cout << "nThe actualframerate is =" << out << " f/sn";
}
你有没有可能卡在while(cin>>...(循环中?因为我正在尝试复制您的问题。
删除它的工作原理是:
cin >> id >> name >> m1 >> m2 >> m3 >> m4 >> m5;
outputFile << id << " " << name << " " << m1 << " " << m2 << " " << m3 << " " << m4 << " " << m5;
相关文章:
- 当回溯以零开始时,如何调试崩溃
- 将对象数组的引用传递给函数
- 什么时候在C++中返回常量引用是个好主意
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- 何时在引用或唯一指针上使用移动语义
- 如何在c++中使用引用实现类似python的行为
- 编译C++时未定义的引用
- Ctypes wstring通过引用传递
- c++r值引用应用于函数指针
- 理解c++中的引用
- C++取消引用指针.为什么会发生变化
- 如何修复此错误:未定义对"距离(浮点数,浮点数,浮点数,浮点数,浮点数)"的引用
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- 强制转换为引用类型
- 引用一个已擦除类型(void*)的指针
- 向量元素的引用地址与它所指向的向量元素的地址不同.为什么
- 具有默认值的引用获取函数
- 如何使用基类指针引用派生类成员
- 如何在调试中通过传递引用开始