- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
main.cpp
#include <iostream>
#include <fstream>
#include "steganography.h" // call steganography class
const int arrSize = 30000;//array for contains pixels
using namespace std;
int main()
{
char FileName[20] = "new.txt";
char NewFile[20] = "new.ppm";
char arrPixel[arrSize] = {};
int count = 0;
int option;
Steganography A;//create the reference of steganopragpy class
cout<<"Choose Enocde/Decode[1/2]"; // take option from user
cin>>option;
switch(option)
{
case 1:
cout << "Enter PPM File Name" << endl;
cin>>FileName;
cout << "Enter Output File Name"<< endl;
cin>>NewFile;
A.readImage(FileName, arrPixel);//call readImage method
cout << "Encoded Successfully completed:" << endl;
A.printImage( NewFile, arrPixel);//write ppm
break;
case 2:
cout << "Enter Input File Name" << endl;
cin>>FileName;
cout << "Enter Output PPM File Name"<< endl;
cin>>NewFile;
A.readCipherText( NewFile, arrPixel);//call read file method
cout << "Decoded Successfully completed:" << endl;
A.printCipherText(FileName, arrPixel);//write ppm
break;
default:
cout<<"wrong choice";
}
// cout << NewFile << endl;
for(int ct = 0; ct > arrSize; ct++)
{
cout << arrPixel[ct];
}
return 0;
}
隐写术.cpp
#include <iostream>
#include <fstream>
#include <string>
#include "steganography.h" // call steganography class
const int arrSize = 30000;//array for contains pixels
using namespace std;
Steganography::Steganography()//call steganography constructor
{
char arrPixel[arrSize] = {};
}
void Steganography::readImage(char* FileName, char* arrPixel)//read image
{
ifstream infile (FileName);//open file
if(infile.is_open())
{
for(int count = 0; count < arrSize; count++)
{
infile >> noskipws >> arrPixel[count];
}
}
else
{
cout << "Error opening new file." << endl;
//abort();
}
infile.close();
}
void Steganography::readCipherText(char* FileName, char* arrPixel)//read text file contains ppm info
{
ifstream infile (FileName);
if(infile.is_open())
{
for(int count = 0; count < arrSize; count++)
{
infile >> noskipws >> arrPixel[count];
}
}
else
{
cout << "Error opening new file." << endl;
//abort();
}
infile.close();
}
void Steganography::printImage(char* NewFile, char* arrPixel)//write image
{
ofstream outfile (NewFile);
if(outfile.is_open())
{
int count = arrSize;
for(int i = 0; i < (count - 1); i++)
{
outfile << arrPixel[i];
}
}
else
{
cout << "Error opening new file." << endl;
// abort();
}
outfile.close();
}
void Steganography::printCipherText(char* NewFile, char* arrPixel)//write ppm file
{
ofstream outfile (NewFile);
if(outfile.is_open())
{
int count = arrSize;
for(int i = 0; i < (count - 1); i++)
{
outfile << arrPixel[i];
}
}
else
{
cout << "Error opening new file." << endl;
// abort();
}
outfile.close();
}
隐写术.h
#ifndef STEGANOGRAPHY_H
#define STEGANOGRAPHY_H
#include <string>
#include <vector>
class Steganography {
private:
// Image header
std::string image_type;
int width, height;
int max_color_depth;
// Image data
std::vector<int> color_data;
// Hidden data
std::string ciphertext;
int getNthBit(char cipher_char, int n);
public:
Steganography(void); //Constructor
void readImage(char*,char*);
void printImage(char*,char*);
void readCipherText(char*,char*);
void printCipherText(char*,char*);
void cleanImage();
void encipher();
void decipher();
};
#endif
当我编译时,我收到这个警告:
steganography.cpp: In constructor ‘Steganography::Steganography()’:
steganography.cpp:11:10: warning: unused variable ‘arrPixel’ [-Wunused-variable]
谁能帮我解决这个问题。另外,我必须写下这一行 const int arrSize = 30000;在 Main.cpp 和 steganography.cpp 中以避免出错,有没有办法只在 steganography.cpp 上写入它而不会出错?
最佳答案
这里:
Steganography::Steganography()//call steganography constructor
{
char arrPixel[arrSize] = {};
}
您声明了一个名为 arrPixel
的局部变量,但您没有使用它。您可以删除该行。
请注意,您收到的是警告,而不是错误。
关于c++ - 警告 : unused variable ‘arrPixel’ [-Wunused-variable],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21770082/
我正在学校作业中实现单例设计模式,这是我的类头文件: class Scheduler { public: static Scheduler * instance(); ~Schedul
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
最近我开始用C++编程了(我是Java出身的,有点零钱哈哈)。在 Windows 下一切正常。问题是我切换到 Linux,这就是我遇到编译器问题的地方。通常当你声明一个变量但没有被使用时,编译器会显示
我是 c++ 新手。 我想忽略警告 -Wunused-result 我猜是因为 -Wall 标志而弹出的。 我在网上搜索了一下,发现这是我可以通过声明一个pragma 来忽略它。我对 pragma 了
我有以下代码,在使用 gcc-4.6 编译时我收到警告: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
我将Wunused-parameter用于我的项目,但我想让它忽略3rd Party header (特定目录中的 header )。有什么办法可以用cmake设置它吗? 我目前正在像这样设置编译器选
我使用的是 GCC 版本 8.2在几段代码中,我使用了小函数。我对每一项功能都进行了测试(即 Unity 框架测试)。测试被定义为 #define 宏,测试非常具体的事情。例如,如果一个数字是正数
以下代码生成一个警告,指出未使用 temp(这是真的): #include int f() { return 5; } int main() { if(const int& temp = f
我只是花了一些时间来找出为什么可变集没有正确地与自身相交与另一组,使用 [someMutableSet intersectsSet:anotherSet]; // not the best i
我正在使用以下命令构建 C++14。 g++ -std=c++14 -O2 -Wall -pedantic -pthread main.cpp && ./a.out 如何将 -Wunused-vari
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我试图通过使用 GCC 的 -Wunused-function 标志在我的代码库中找到未使用的函数。 如我所料,使用 gcc -Wall -Wunused-function main.cpp 编译以下
这是我的代码: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-variable" //__attribute
我使用 Ideone.com 编译了下面的代码,弹出了以下警告。 rtctimer.c: In function 'rtctimer_next_tick': rtctimer.c:87.7: warn
我已经搜索并没有真正找到并理解这个错误。奇怪的是,我只得到 c、d、e 的错误,而不是 a 和 b 或它们所有的错误。 程序是关于双链表的。 当我编译时会发生这种情况: gcc -Wall -g -c
我正在尝试使用Ubuntu将Cross编译为Android内核。 成功设置menuconfig后,并使用以下选项进行编译: make ARCH=arm CROSS_COMPILE="arm-bravo
所以我试图找出 while 循环和大多数 if 语句,所以我尝试制作这个小游戏,其中你有一定的生命值,怪物也有,只要你们都有超过 0 的生命值,循环就会运行,所以每个循环怪物都会对你造成 50 点伤害
main.cpp #include #include #include "steganography.h" // call steganography class const int arrSi
我有一个使用 SDL 的 C++ 项目。 我在编译时遇到这个错误,我不知道如何解决。 它说: Source/Classes/game.cpp:15:15: advarsel(this means 'w
我已经盯着它看了很久,但不明白为什么它会在 for 循环语句中给我一个警告。 //looks for a certain account by name in the provided list, r
我是一名优秀的程序员,十分优秀!