-
Notifications
You must be signed in to change notification settings - Fork 4
/
qrgen.cpp
39 lines (33 loc) · 988 Bytes
/
qrgen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <fstream>
#include <string>
#include <qrencode.h>
using namespace std;
unsigned char *QRGen(string dataString)//Now takes single string param
{
//string sampleDataString = "It Works!!!"; Keep for backup, in case input does not work.
if(dataString != NULL || dataString != "") //make sure that the input actually contains data first.
{
QRcode *qrc;
qrc = new QRcode;
qrc = QRcode_encodeString8bit(dataString.c_str(),4,QR_ECLEVEL_Q);
cout << "The QRC data string should be " << dataString << endl; //Ensure the input is correct.
return qrc->data;
}
else //convert -1 to unsigned char* and return it for error;
{
unsigned char *error;
error = new unsigned char;
*error = (unsigned char)-1;
return *error;
}
}
void test()//function to test QRGen
{
cout << QRGen("Hello, World") << endl;//should print out QRC data from QRGen
}
int main()//used to call test function
{
test();
return 0;
}