adding new hard disk to linux VM :-
-----------------------------------
1. Add new HDD via VM settings.
2. power on VM.
3. run following command as root user.
# echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan >/dev/null
# lsblk <-|(i.e. press Enter )
this will show you newlly added HDDs. But right now you can not use directely.
First you have to create filesystem in it and make filesystem of "xfs". Then only you can
get it in your OS. So do these :-
for example these are mine output :-
------------------------------------------------
[root@ora12cserver oracle]# echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan >/dev/null
[root@ora12cserver oracle]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1000M 0 part /boot
├─sda2 8:2 0 20G 0 part /oraGridDisk1
├─sda3 8:3 0 20G 0 part /oraGridDisk2
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 16G 0 part [SWAP]
├─sda6 8:6 0 15G 0 part /oraGridDisk3
└─sda7 8:7 0 28G 0 part /
sdb 8:16 0 20G 0 disk
sdc 8:32 0 20G 0 disk
sr0 11:0 1 4.1G 0 rom /run/media/oracle/OL-7.5 Server.x86_64
------------------------------------------------
Now to create new partition fire these commands :-
# fdisk /dv/sdb
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ora12cserver oracle]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1000M 0 part /boot
├─sda2 8:2 0 20G 0 part /oraGridDisk1
├─sda3 8:3 0 20G 0 part /oraGridDisk2
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 16G 0 part [SWAP]
├─sda6 8:6 0 15G 0 part /oraGridDisk3
└─sda7 8:7 0 28G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part
sdc 8:32 0 20G 0 disk
sr0 11:0 1 4.1G 0 rom /run/media/oracle/OL-7.5 Server.x86_64
then :-
[root@ora12cserver oracle]# mkfs.xfs /dev/sdb1
now
[root@ora12cserver oracle]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x0d073c9d.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ora12cserver oracle]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1000M 0 part /boot
├─sda2 8:2 0 20G 0 part /oraGridDisk1
├─sda3 8:3 0 20G 0 part /oraGridDisk2
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 16G 0 part [SWAP]
├─sda6 8:6 0 15G 0 part /oraGridDisk3
└─sda7 8:7 0 28G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 20G 0 part
sr0 11:0 1 4.1G 0 rom /run/media/oracle/OL-7.5 Server.x86_64
[root@ora12cserver oracle]# mount /dev/sdb1 /mnt/sdb1
[root@ora12cserver oracle]# mkfs.xfs /dev/sdc1
meta-data=/dev/sdc1 isize=256 agcount=4, agsize=1310656 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0, sparse=0
data = bsize=4096 blocks=5242624, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@ora12cserver oracle]# mount /dev/sdc1 /mnt/sdc1
[root@ora12cserver oracle]#
Learn In Linux Plateform
Tuesday, April 21, 2026
Adding new harddisk into VM Linux
Wednesday, November 5, 2025
How to enable shared folders in linux in VM Ware workstation 17 for Centos 8-9
go to VM -> settings -> options -> shared folders -> enabled :-
add folders and set "always enabled".
On VM of centos or Oracle linux 8-9 ->
# gedit /etc/fstab
add entry :-
vmhgfs-fuse /mnt/hgfs fuse defaults,allow_other 0 0
save and exit.
run command :-
# systemctl daemon-reload
now you have :-
/mnt/hgfs/<shared folders>
you may need to install open-vm-tools. Just open ISO file of OS and search for
"open-vm" copy all rpms and save into folder. Install all of them and do given above.
In CentOS 9 you may need to install firewall rpms.
enjoy.
Saturday, November 1, 2025
Date manipulation programm and its shared library in C++ CLI( terminal )
Date manipulation programm and it's shared library "date-manip.h" and
"libdate-manip.so". Build it as I discussed in earlier posts.
Here is program for Date manipulation in C++. You may build its shared library, as I discused in some previous blogs. Add header and attach shared library and use it's functionalities.
Here SDate is a public structure, so can be accessed to get individual elements as dd(day), MM(month) and yy(year). In string format it is complete string of date as "12/04/2034". Which is used here in all places, needed date as string in complete form and SDate to get its elements in different integer variables.
Here you need "validator shared library" and I posted already this library code.
file :- date-manip.h
--------------------
#ifndef DATE-MANIP_H_INCLUDED
#define DATE-MANIP_H_INCLUDED
#include <validator/validator.h>
#include <string>
class CDateManip
{
public:
struct SDate
{
int yy, MM, dd;
};
CDateManip();
virtual ~CDateManip();
CDateManip(const CDateManip& other);
CDateManip& operator=(const CDateManip& other);
bool splitDate(std::string strDate, SDate *dt);
void formDate(SDate dte, std::string *strDate);
bool isLeapYear(int yy);
bool isValidDate(std::string strDate);
bool julian(SDate dt, int *j);
void reverseJulian(int j,int year, SDate *dt);
bool addDays(std::string strDate, int days, std::string *strNewDate);
bool addMonths(std::string strDate, int imonths, std::string *newDate);
bool addYear(std::string strDate, int iyear, std::string *strNewDate);
int compareDate(std::string strFirstDate, std::string strSecondDate);
int diffDays(std::string strFirstDate, std::string strSecondDate);
void diffYMD(std::string strDate1, std::string strDate2, SDate *dt);
bool subDays(std::string strDate, int days, std::string *newDate);
bool subMonths(std::string strDate, int months, std::string *newDate);
bool subYears(std::string strDate, int year, std::string *newDate);
std::string weekDays(std::string strDate);
};
#endif // DATE-MANIP_H_INCLUDED
----------------------------------------------------------------------------
file :- date-manip.cpp
-----------------------------------------
#include "date-manip.h"
#include <string>
using std::string;
using std::endl;
using std::to_string;
CDateManip::CDateManip()
{
//ctor
}
CDateManip::~CDateManip()
{
//dtor
}
CDateManip::CDateManip(const CDateManip& other)
{
//copy ctor
}
CDateManip& CDateManip::operator=(const CDateManip& rhs)
{
if (this == &rhs) return *this; // handle self assignment
//assignment operator
return *this;
}
bool CDateManip::splitDate(string strDate, SDate *dt)
{
string strdd, strMM, stryy;
int diff;
bool tf;
int pos_first = strDate.find('/');
if(pos_first == string::npos)
{
return false;
}
int pos_sec = strDate.find('/', pos_first + 1);
if(pos_sec == string::npos)
{
return false;
}
diff = pos_sec - pos_first;
strdd = strDate.substr(0, pos_first);
strMM = strDate.substr(pos_first + 1, diff-1);
stryy = strDate.substr(pos_sec + 1);
tf = CValidator::intvalidator(strdd);
if(tf == false)
{
return false;
}
dt->dd = std::stoi(strdd);
tf = CValidator::intvalidator(strMM);
if(tf == false)
{
return false;
}
dt->MM = std::stoi(strMM);
tf = CValidator::intvalidator(stryy);
if(tf == false)
{
return false;
}
dt->yy = std::stoi(stryy);
}
void CDateManip::formDate(SDate dte, string *strDate)
{
if(dte.dd < 10)
{
*strDate = "0" + to_string(dte.dd);
}
else
{
*strDate = to_string(dte.dd);
}
*strDate += "/";
if(dte.MM < 10)
{
*strDate += "0" + to_string(dte.MM);
}
else
{
*strDate += to_string(dte.MM);
}
*strDate += "/";
if(dte.yy < 10)
{
*strDate += "0" + to_string(dte.yy);
}
else
{
*strDate += to_string(dte.yy);
}
}
bool CDateManip::isLeapYear(int yy)
{
if( (yy%4 == 0 && yy%100 != 0) || yy%400 == 0)
return true;
else
return false;
}
bool CDateManip::isValidDate(string strDate)
{
int dd, MM, yy;
SDate *dte = new SDate;
bool tf;
if(strDate.length() > 10)
{
return false;
}
tf = splitDate(strDate, dte);
if(tf == false)
{
return false;
}
if(dte->dd == 0 || dte->MM == 0 || dte->yy == 0) return false;
if(dte->dd < 1 || dte->dd > 31 || dte->MM < 1 || dte->MM > 12) return false;
if(dte->MM == 2)
{
if(dte->dd == 29 && (isLeapYear(dte->yy) == true )) return true;
if(dte->dd > 28) return false;
}
if(dte->MM == 4 || dte->MM == 6 || dte->MM == 9 || dte->MM == 11)
{
if(dte->dd > 30) return false;
}
delete dte;
return true;
}
bool CDateManip::julian(SDate dt, int *j)
{
if( dt.MM < 1 || dt.MM > 11)
{
return false;
}
*j = dt.dd;
switch(dt.MM - 1)
{
case 11:
*j += 30;
case 10:
*j += 31;
case 9:
*j += 30;
case 8:
*j += 31;
case 7:
*j += 31;
case 6:
*j += 30;
case 5:
*j += 31;
case 4:
*j += 30;
case 3:
*j += 31;
case 2:
*j += 28;
case 1:
*j += 31;
}
if(isLeapYear(dt.yy))
{
*j += 1;
}
return true;
}
void CDateManip::reverseJulian(int j,int year, SDate *dt)
{
int i;
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if(isLeapYear(year) == true)
{
month[2] = 29;
}
for(i = 1; i <= 12; i++)
{
if(j <= month[i])
{
break;
}
j -= month[i];
}
dt->yy = year;
dt->MM = i;
dt->dd = j;
}
bool CDateManip::addDays(string strDate, int days, string *strNewDate)
{
int d1,d2, m1, m2, y1, y2;
int d, m, y;
int j1, j2, diff, yrs;
int daysofyear;
SDate *dt1 = new SDate;
SDate *dt2 = new SDate;
bool tf = splitDate(strDate, dt1);
if(tf == false)
{
return false;
}
julian(*dt1, &j1);
if(isLeapYear(dt1->yy) == true)
{
diff = 366 - j1;
}
else
{
diff = 365 - j1;
}
if(days <= diff)
{
j2 = j1 + days;
dt2->yy = dt1->yy;
}
else
{
days -= diff;
dt2->yy = dt1->yy + 1;
if(isLeapYear(dt2->yy) == true)
{
daysofyear = 366;
}
else
{
daysofyear = 365;
}
while(days >= daysofyear)
{
if(isLeapYear(dt2->yy ) == true)
{
days -= 366;
}
else
{
days -= 365;
}
dt2->yy++;
daysofyear = isLeapYear(dt2->yy)?366:365;
}
j2 = days;
}
reverseJulian(j2, dt2->yy, dt2);
formDate(*dt2, strNewDate);
delete dt1, dt2;
return true;
}
bool CDateManip::addMonths(string strDate, int imonths, string *newDate)
{
SDate dt;
int quot, rem;
bool tf = splitDate(strDate, &dt);
if(tf == false)
{
return false;
}
quot = imonths / 12;
rem = imonths % 12;
dt.yy += quot;
dt.MM += rem;
if(dt.MM > 12)
{
dt.MM -= 12;
dt.yy += 1;
}
if(dt.MM == 2 && dt.dd == 29)
{
if(dt.MM == 2 && dt.dd == 29)
{
if(isLeapYear(dt.yy) == true)
{
dt.dd = 29;
}
else
{
dt.dd = 28;
}
}
}
if((dt.MM == 4 || dt.MM == 6 || dt.MM == 9 || dt.MM == 11) && dt.dd == 31)
{
dt.dd = 30;
}
formDate(dt, newDate);
return true;
}
bool CDateManip::addYear(string strDate, int iyear, string *strNewDate)
{
SDate *dte = new SDate;
bool tf = splitDate(strDate, dte);
if(tf == false)
{
return false;
}
dte->yy += iyear;
if(dte->dd == 29 && dte->MM == 2 && isLeapYear(dte->yy))
{
dte->dd = 28;
}
formDate(*dte, strNewDate);
return true;
}
int CDateManip::compareDate(string strFirstDate, string strSecondDate)
{
SDate *dt1 = new SDate;
SDate *dt2 = new SDate;
splitDate(strFirstDate, dt1);
splitDate(strSecondDate, dt2);
if(dt1->yy < dt2->yy)
return 1;
if(dt1->yy > dt2->yy)
return -1;
if(dt1->MM < dt2->MM)
return 1;
if(dt1->MM > dt2->MM)
return -1;
if(dt1->dd < dt2->dd)
return 1;
if(dt1->dd > dt2->dd)
return -1;
return 0;
}
int CDateManip::diffDays(string strFirstDate, string strSecondDate)
{
SDate dt1, dt2;
int j1, j2, days, d = 0, i;
splitDate(strFirstDate, &dt1);
splitDate(strSecondDate, &dt2);
julian(dt1, &j1);
julian(dt2, &j2);
if(dt1.yy == dt2.yy)
{
return (j2 - j1);
}
for(i = dt1.yy + 1; i <= dt2.yy-1; i++)
{
if(isLeapYear(i) == true)
{
d += 366;
}
else
{
d += 365;
}
}
if(isLeapYear(dt1.yy ) == true)
{
days = 366 - j1 + d + j2;
}
else
{
days = 365 - j1 + d + j2;
}
return days;
}
void CDateManip::diffYMD(string strDate1, string strDate2, SDate *dt)
{
SDate dt1, dt2;
splitDate(strDate1, &dt1);
splitDate(strDate2, &dt2);
if(dt2.dd < dt1.yy)
{
if(dt2.MM == 3)
{
if(isLeapYear(dt2.yy) == true)
{
dt2.dd += 29;
}
else
{
dt2.dd += 28;
}
}
else if(dt2.MM == 5 || dt2.MM == 7 || dt2.MM == 10 || dt2.MM == 12)
{
dt2.dd += 30;
}
else
{
dt2.dd += 31;
}
dt2.MM -= 1;
}
if(dt2.MM < dt1.MM)
{
dt2.yy -= 1;
dt2.MM += 12;
}
dt->yy = dt2.yy - dt1.yy;
dt->MM = dt2.MM - dt1.MM;
dt->dd = dt2.dd - dt1.dd;
}
bool CDateManip::subDays(string strDate, int days, string *newDate)
{
SDate dt1, dt2;
int j1, j2, temp;
bool tf;
splitDate(strDate, &dt1);
tf = julian(dt1, &j1);
if(tf == false)
{
return false;
}
if(days < j1)
{
j2 = j1 - days;
dt2.yy = dt1.yy;
}
else
{
days -= j1;
dt2.yy = dt1.yy - 1;
temp = isLeapYear(dt2.yy) ? 366 : 365;
while(days >= temp)
{
if(isLeapYear(dt2.yy) == true)
{
days -= 366;
}
else
{
days -= 365;
}
dt2.yy--;
temp = isLeapYear(dt2.yy) ? 366 : 365;
}
j2 = isLeapYear(dt2.yy) ? 366 - days : 365 - days;
}
SDate dt3;
reverseJulian(j2, dt2.yy, &dt3);
formDate(dt3, newDate);
return true;
}
bool CDateManip::subMonths(string strDate, int months, string *newDate)
{
SDate dt;
bool tf;
int j;
int quot;
int rem;
tf = julian(dt, &j);
if(tf == false)
{
return false;
}
quot = dt.yy / 12;
rem = dt.yy % 12;
dt.yy -= quot;
dt.MM -= rem;
if(dt.MM < 0)
{
dt.yy -= 1;
dt.MM += 12;
}
if(dt.MM == 2 && dt.dd >= 29)
{
if(isLeapYear(dt.yy) == true)
{
dt.dd = 29;
}
else if(isLeapYear(dt.yy) == false)
{
dt.dd = 28;
}
}
if( (dt.MM == 4 || dt.MM == 6 || dt.MM == 9 || dt.MM == 11) && dt.dd == 31)
{
dt.dd = 30;
}
formDate(dt, newDate);
return true;
}
bool CDateManip::subYears(string strDate, int year, string *newDate)
{
SDate dt;
bool tf = splitDate(strDate, &dt);
if(tf == true)
{
return false;
}
dt.yy -= year;
if(dt.dd == 29 && dt.MM == 2 && !isLeapYear(dt.yy))
{
dt.dd = 28;
}
formDate(dt, newDate);
return true;
}
string CDateManip::weekDays(string strDate)
{
SDate dt;
string weekday;
int j;
int f;
int h;
int fh;
splitDate(strDate, &dt);
bool tf = julian(dt, &j);
if(tf == false)
{
return false;
}
f = (dt.yy - 1)/4;
h = (dt.yy - 1)/100;
fh = (dt.yy - 1)/400;
int day = (dt.yy + j + f - h + fh) % 7;
switch(day)
{
case 0:
weekday = "Saturday";
break;
case 1:
weekday = "Sunday";
break;
case 2:
weekday = "Monday";
break;
case 3:
weekday = "Tuesday";
break;
case 4:
weekday = "Wednesday";
break;
case 5:
weekday = "Thursday";
break;
case 6:
weekday = "Friday";
break;
}
return weekday;
}
Saturday, September 6, 2025
How to check even or odd number without divide by 2
How to check even or odd number without divide by 2. :-
-------------------------------------------------------
here is a program that checks even/odd number without divide by two. Here is theory
let start with number, consider number table as :-
decimal numbers it's binary last digit ( LSB )
------------------ --------------- ------
1 -> odd 0001 1
2 -> even 0010 0
3 -> odd 0011 1
4 -> even 0100 0
5 -> odd 0101 1
6 -> even 0110 0
7 -> odd 0111 1
8 -> even 1000 0
9 -> odd 1001 1
10 -> even 1010 0
.
.
.
.
Now it is clear that in number table after every odd ( started from 1) there is an even number, and after every even there is odd number. And in their binary form, LSB of odd is " 1 ", and LSB of even is " 0 ".
So by using bitwise "and" operation ( & ) with a char having LSB " 1 ", i.e.
0x01 ( 0000 0001 ) we can chack number's LSB is " 1 " or " 0 ". and from that we can determine even or odd. Here is a program :-
#include <iostream>
using namespace std;
bool evenodd(int num)
{
char *pch;
pch = (char*)(&num);
int i = (*pch) & (0x01);
if(i == 0)
{
return true;
}
else if(i == 1)
{
return false;
}
}
int main()
{
int i;
cout << "Enter integer to check even/odd : ";
cin >> i;
bool tf = evenodd(i);
if(tf == true)
{
cout << "even number" << endl;
}
else
{
cout << "odd number" << endl;
}
return 0;
}
OUTPUT of program :-
--------------------
[rahul@kaljayi Debug]$ ./prime-num
Enter integer to check even/odd : 1
odd number
[rahul@kaljayi Debug]$ ./prime-num
Enter integer to check even/odd : 3
odd number
[rahul@kaljayi Debug]$ ./prime-num
Enter integer to check even/odd : 5
odd number
[rahul@kaljayi Debug]$ ./prime-num
Enter integer to check even/odd : 4
even number
[rahul@kaljayi Debug]$ ./prime-num
Enter integer to check even/odd : 121212
even number
[rahul@kaljayi Debug]$ ./prime-num
Enter integer to check even/odd : 1212121
odd number
[rahul@kaljayi Debug]$ ./prime-num
Enter integer to check even/odd : 12121223
odd number
[rahul@kaljayi Debug]$
Sunday, May 18, 2025
About Segmentation fault in Linux
in linux segmentation fault is :-
-------------------------------------------------
accessing unauthorized memory for "reading" or "writing" is segmentation fault.
For example :-
let you have created a class
class ABCD
{
// here you have created a pointer variable as :-
MYSQL *mysql;
};
Now in somewhere your project you used this pointer without initialized it, somethig like this :-
void ABCD::myfunction-abcd()
{
....................
....................
mysql->...................... // or something like that
/*
then in above line you will get "segmentation fault" error in console and your program will be terminated immediately. Because when we, create object, program will give you a memory allocated for your object. And above pointer will be allocated a memory. But here program or compiler will not initialize it by default, it's your responsibility to initialize it. Now because of that allocated memory for above pointer will have garbage value. And in this stage pointer is called "dangling pointer". And because of that, pointer will point to any location in memory, so "reading" or "writing" by this pointer is "segmentation fault", because this pointer is pointing to unauthorized memory. and that's all.................
*/
}
Sunday, June 9, 2024
trim a string in C++
bool trim(string *str)
{
int atstart = 0, atend = -1;
string str2;
if(str->length() != 0)
{
str2 = *str;
}
else
{
return false;
}
for(int i = 0; i < str2.size(); i++)
{
if(str2[i] != ' ')
{
atstart = i;
break;
}
}
for(int i = str2.size()-1; i >= 0; i--)
{
if(str2[i] != ' ')
{
atend = i;
break;
}
}
str->clear();
for(int i = atstart; i <= atend; i++)
{
*str += str2[i];
}
if(str->length() == 0)
{
return false;
}
return true;
}
Sunday, April 21, 2024
building QMYSQL sqldriver plugin for Qt-5.12, get rid of error '-Wdate-time', make it loaded
how to connect mysql and Qt 5.12 and building QMYSQL driver & make them loaded, get rid of error '-Wdate-time'
I have centos 7 in one client as VM with MySQL client and mysql server in second VM. In client I've installed Qt 5.12. To install MySQL sqldriver fire this command
[root@C-Client mysql]# /opt/Qt5.12.12/5.12.12/gcc_64/bin/qmake -- MYSQL_INCDIR=/usr/include/mysql -- MYSQL_LIBDIR=/usr/lib64/mysql/ -lrt -ldl -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto mysql.pro
but unfortunetly it showed me following error :-
"g++: error: unrecognized command line option ‘-Wdate-time’"
as here :-
[root@C-Client mysql]# make
g++ -c -pipe -O2 -g -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I/opt/Qt5.12.12/5.12.12/gcc_64/include/QtSql/5.12.12 -I/opt/Qt5.12.12/5.12.12/gcc_64/include/QtSql/5.12.12/QtSql -I/opt/Qt5.12.12/5.12.12/gcc_64/include/QtCore/5.12.12 -I/opt/Qt5.12.12/5.12.12/gcc_64/include/QtCore/5.12.12/QtCore -I/opt/Qt5.12.12/5.12.12/gcc_64/include -I/opt/Qt5.12.12/5.12.12/gcc_64/include/QtSql -I/opt/Qt5.12.12/5.12.12/gcc_64/include/QtCore -I.moc -isystem /usr/include/mysql -I/home/qt/openssl-1.1.1k/include -I/opt/Qt5.12.12/5.12.12/gcc_64/mkspecs/linux-g++ -o .obj/qsql_mysql.o qsql_mysql.cpp
g++: error: unrecognized command line option ‘-Wdate-time’
make: *** [.obj/qsql_mysql.o] Error 1
Now to recover this, do this :-
go to installation dir as mine is : "/opt/Qt5.12.12/5.12.12/Src/qtbase/src/plugins/sqldrivers/mysql". fire following command :
# chmod 777 Makefile
# gedit Makefile
search for "-Wdate-time" by Pressing Ctrl + f. There will be two places by this search. delete "-Wdate-time" on both places, save & close file Makefile. Re-run make command as :-
# make
Now this will give you no error. Then install plugin as :-
# make install
this copies binary sql-driver in to appropriate dir in Qt folder automatically.
# make clean
last line to clean binaries generated during process.
now your plugin is installed. Test it as you want.
Friday, April 12, 2024
Menus, Menus, Menus & Menus one inside another upto any level in terminal Centos 7 and its shared library.
You can implement many more menus. Just Define a class of your need declare a function getFunctionOfChoice() ( or as you want you can give name). Also to call menu inside CMenu class you need to define your own menu object.
To build a menu use std::vector<std::string> mineMenu. use function push_back(/*arguments as string only*/).
pass this menu to CMenu::getChoice( your-menu-pointer->menu-Vector, "Header Of Your Choice to display", lastLine);
this will return index number, you entered to select from menu item. Get it in a int variable choice. Then pass it to
switch statements. Which will handle so-on. As given here.
You can also build its shared library as "libmenus.so", as I explored in old blogs. And then add its header file and library file in your project and use it as defined here.
I've added two shared libraries named : "libvalidator.so" & "libclrscr-getch.so". I already posted those, how to build libraires
and how to attach these in our project. Please refer previous posts.
you can also build this project as shared library and call this lib to another project without including source code. As we did with "libvalidator.so" and "libclrscr-getch.so". its may be "libmenus.so" or as you wish.
To run this program do all these :
1. Set "so library files" i.e. shared libraries to path "/opt/so-files/sos/.". Then set library path to LD_LIBRARY_PATH for this dir. Then run MENUs.
as follows :-
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/so-files/sos/clrscr-getch-so:/opt/so-files/sos/validators
or
you can put header files in "/usr/include/clrscr-getch" "/usr/include/menus/" "/usr/include/validator"
this will call headers without adding header file path in our project
and lib files in "/usr/lib64/clrscr-getch" "/usr/lib64/menus" "/usr/lib64/validtor"
here you must give full path for each library file containing directory.
then run this executable from any where on your system. Mine executable file name is : Menus , run this as follows :-
$ ./Menus <-| ( i.e. press Enter )
main.cpp :-
-----------
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include "CMenu.h"
#include "CLinkedList.h"
#include "CQueue.h"
#include "CSorting.h"
#include "CVecMenu.h"
using std::cout;
using std::cin;
using std::endl;
using std::string;
int main()
{
// CLinkedlist *llist = new CLinkedlist;
CValidator *validator = new CValidator;
CClrscrGetch *get = new CClrscrGetch;
CMenu *menu = new CMenu;
CVecMenu *vecmenu = new CVecMenu;
CLinkedList *llist = new CLinkedList;
CQueue *qu = new CQueue;
CSorting *sor = new CSorting;
int choice = 0;
do
{
get->clrscr();
int lastLine = 0;
choice = menu->getChoice(vecmenu->mainMenu, "MAIN MENU", lastLine);
switch(choice)
{
case 1:
get->clrscr();
llist->getFunctionOfChoice();
break;
case 2:
get->clrscr();
qu->getFunctionOfChoice();
// menu->get->getch();
break;
case 3:
cout << " Stack ";
menu->get->getch();
break;
case 4:
// cout << " Sorting ";
sor->getFunctionOfChoice();
// menu->get->getch();
break;
case 5:
cout << " Searching ";
menu->get->getch();
break;
case 6:
cout << " Trees ";
menu->get->getch();
break;
case 7:
cout << " Graphs ";
menu->get->getch();
break;
case 8:
cout << " Sparse Metrices ";
menu->get->getch();
break;
case 9:
get->clrscr();
exit(0);
}
}while(choice != 9 );
return 0;
}
/*
You can implement many more menus. Just Define a class of your need declare a function getFunctionOfChoice()
( or as you want you can give name). Also to call menu inside CMenu class you need to define your own menu object.
To build a menu use std::vector<std::string> mineMenu. use function push_cack(/*arguments as string only*//*).
pass this menu to CMenu::getChoice( your-menu-pointer->menu-Vector, "Header Of Your Choice toi display", lastLine);
this will return index number, you entered to select from menu item. Get it in a int variable choice. Then pass it to
switch statements. Which will handle so-on. As given above.
*/
--------------------------------------------------------------------------
File : CVecMenu.h :-
--------------------
#ifndef CVECMENU_H
#define CVECMENU_H
#include <vector>
#include <string>
class CVecMenu
{
public:
CVecMenu();
virtual ~CVecMenu();
CVecMenu(const CVecMenu& other);
CVecMenu& operator=(const CVecMenu& other);
std::vector<std::string> menu;
std::vector<std::string>::const_iterator iter;
std::vector<std::string> mainMenu;
std::vector<std::string>::const_iterator iterMainMenu;
std::vector<std::string> stackMenu;
std::vector<std::string>::const_iterator iterStackMenu;
std::vector<std::string> queueMenu;
std::vector<std::string>::const_iterator iterQueueMenu;
std::vector<std::string> listMenu;
std::vector<std::string>::const_iterator iterListMenu;
std::vector<std::string> listSubMenu1;
std::vector<std::string>::const_iterator iterListSubMenu1;
std::vector<std::string> listOperationalMenu;
std::vector<std::string>::const_iterator iterListOperationalMenu;
std::vector<std::string> treeMenu;
std::vector<std::string>::const_iterator iterTreeMenu;
std::vector<std::string> sortingMenu;
std::vector<std::string>::const_iterator iterSortingMenu;
std::vector<std::string> searchMenu;
std::vector<std::string>::const_iterator iterSearchMenu;
std::vector<std::string> graphMenu;
std::vector<std::string>::const_iterator iterGraphMenu;
std::vector<std::string> sparseMetricesMenu;
std::vector<std::string>::const_iterator iterSparseMtrices;
};
#endif // CVECMENU_H
--------------------------------------------------------------------------
File : CVecMenu.cpp :-
----------------------
#include "CVecMenu.h"
CVecMenu::CVecMenu()
{
//ctor
mainMenu.push_back("1. Linked List ");
mainMenu.push_back("2. Queue ");
mainMenu.push_back("3. Stack ");
mainMenu.push_back("4. Sorting ");
mainMenu.push_back("5. Searching ");
mainMenu.push_back("6. Trees ");
mainMenu.push_back("7. Graphs ");
mainMenu.push_back("8. Sparse Metrices ");
mainMenu.push_back("9. Exit ");
listMenu.push_back("1. Singlly Linked List");
listMenu.push_back("2. Doubly Linked List ");
listMenu.push_back("3. Circular linked List ");
listMenu.push_back("4. Doubly Circular Linked List ");
listMenu.push_back("5. Back ");
listMenu.push_back("6. Exit ");
listOperationalMenu.push_back("1. Create ");
listOperationalMenu.push_back("2. Add at beginning ");
listOperationalMenu.push_back("3. Add after node ");
listOperationalMenu.push_back("4. Add Before node ");
listOperationalMenu.push_back("5. Add last ");
listOperationalMenu.push_back("6. Delete first node ");
listOperationalMenu.push_back("7. Delete node before a node ");
listOperationalMenu.push_back("8. Delete node after a node ");
listOperationalMenu.push_back("9. Delete a last node ");
listOperationalMenu.push_back("10. Delete Specified node ");
queueMenu.push_back("1. Sequential Queue as Linked List ");
queueMenu.push_back("2. Priority Queue ");
queueMenu.push_back("3. Circular Queue ");
queueMenu.push_back("4. Dequeue ");
queueMenu.push_back("5. Back");
queueMenu.push_back("6. End");
treeMenu.push_back("1. Binary Tree ");
treeMenu.push_back("2. Binary Search Tree ");
treeMenu.push_back("3. Expressionsin Binary Search Tree ");
treeMenu.push_back("4. Extened Binary Tree ");
treeMenu.push_back("5. Threaded Binary Tree ");
treeMenu.push_back("6. General Trees ");
treeMenu.push_back("7. AVL Trees ");
treeMenu.push_back("8. 2-3 Trees ");
treeMenu.push_back("9. B Tree ");
treeMenu.push_back("10. Heap ");
searchMenu.push_back("1. Linear Search ");
searchMenu.push_back("2. Binary Search ");
sortingMenu.push_back("1. Bubble Sort ");
sortingMenu.push_back("2. Selection Sort ");
sortingMenu.push_back("3. Quick Sort ");
sortingMenu.push_back("4. Insertion Sort ");
sortingMenu.push_back("5. Binary Tree Sort ");
sortingMenu.push_back("6. Heap Sort ");
sortingMenu.push_back("7. Merge Sort ");
sortingMenu.push_back("8. External Sort ");
sortingMenu.push_back("9. Back");
sortingMenu.push_back("10. Exit");
graphMenu.push_back("1. Depth First Search ");
graphMenu.push_back("2. Breadth First Search ");
graphMenu.push_back("3. Spanning Tree ");
graphMenu.push_back("4. Kruskal Algorithms ");
sparseMetricesMenu.push_back("1. Transpose of Sparse Metrices ");
sparseMetricesMenu.push_back("2. Addition of Two Sparse Metrices ");
sparseMetricesMenu.push_back("3. Multiplication of Two Sparse Metrices ");
sparseMetricesMenu.push_back("4. Linked Representation of Sparse Metrices ");
}
CVecMenu::~CVecMenu()
{
//dtor
}
CVecMenu::CVecMenu(const CVecMenu& other)
{
//copy ctor
}
CVecMenu& CVecMenu::operator=(const CVecMenu& rhs)
{
if (this == &rhs) return *this; // handle self assignment
//assignment operator
return *this;
}
--------------------------------------------------------------------------
file : CLinkedList.h :-
-----------------------
#ifndef CLINKEDLIST_H
#define CLINKEDLIST_H
#include "CMenu.h"
#include "CVecMenu.h"
#include <validator/validator.h>
#include <clrscr-getch/clrscr-getch.h>
class CLinkedList
{
public:
CLinkedList();
virtual ~CLinkedList();
CLinkedList(const CLinkedList& other);
CLinkedList& operator=(const CLinkedList& other);
// bool getFuncitonOfChoice(int choice);
int getFunctionOfChoice();
CMenu *menu;
CVecMenu *vecmenu;
CClrscrGetch *get;
CValidator *validator;
protected:
private:
int lastLine;
};
#endif // CLINKEDLIST_H
--------------------------------------------------------------------------
File : ClinkedList.cpp :-
-------------------------
#include "CLinkedList.h"
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::string;
CLinkedList::CLinkedList()
{
//ctor
menu = new CMenu;
vecmenu = new CVecMenu;
get = new CClrscrGetch;
validator = new CValidator;
}
CLinkedList::~CLinkedList()
{
//dtor
delete menu;
delete get;
delete validator;
delete vecmenu;
}
CLinkedList::CLinkedList(const CLinkedList& other)
{
//copy ctor
}
CLinkedList& CLinkedList::operator=(const CLinkedList& rhs)
{
if (this == &rhs) return *this; // handle self assignment
//assignment operator
return *this;
}
int CLinkedList::getFunctionOfChoice()
{
int choice;
do
{
get->clrscr();
choice = menu->getChoice(vecmenu->listMenu, "Linked List Menu", lastLine);
int downline;
switch(choice)
{
case 1:
cout << " Singlly Linked list ";
get->getch();
break;
case 2:
cout << " doubly linked list ";
get->getch();
break;
case 3:
cout << " Circular linked list ";
get->getch();
break;
case 4:
cout << " doubly circular linked list ";
get->getch();
break;
case 5:
break;
case 6:
get->clrscr();
exit(0);
}
}while(choice != 6 && choice != 5);
return 0;
}
--------------------------------------------------------------------------
File : CMenu.h :-
-----------------
#ifndef CMENU_H
#define CMENU_H
#include <vector>
#include <string>
#include <clrscr-getch/clrscr-getch.h>
#include <validator/validator.h>
#include "CString.h"
class CMenu
{
protected:
private:
int i;
int spacer;
int l;
std::string strchoice;
std::string header;
struct winsize w;
bool tf;
// CString *strtrim;
public:
CMenu();
virtual ~CMenu();
CValidator *validator;
CClrscrGetch * get;
int printMenu(std::vector<std::string> menu, std::string header);
int getChoice(std::vector<std::string> choices, std::string header, int &lastLine);
};
#endif // CMENU_H
--------------------------------------------------------------------------
File : CMenu.cpp :-
-------------------
#include "CMenu.h"
#include <ctype.h>
//#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <vector>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::boolalpha;
CMenu::CMenu()
{
//ctor
validator = new CValidator;
get = new CClrscrGetch;
// strtrim = new CString;
}
CMenu::~CMenu()
{
//dtor
delete validator;
delete get;
}
int CMenu::printMenu(vector<string> menuDisplay, string header)
{
vector<string>::const_iterator iterMenu;
menu->get->gotoxy(15, 2);
cout << header;
menu->get->gotoxy(13, 3);
int len = header.length();
spacer = 13 + 3 + len;
for( i = 13; i <= spacer; i++)
{
cout << "-";
}
l = 5;
iterMenu = menuDisplay.begin();
while(iterMenu != menuDisplay.end())
{
menu->get->gotoxy(2, l);
cout << *iterMenu++;
l++;
}
return l;
}
int CMenu::getChoice(vector<string> choice, string header, int &lastLine)
{
int l = 0;
int optionChoice = 0;
int i = 0;
int j = 0;
int downline;
int display = 30;
int limit = 0;
int d = 0;
char c = ' ';
char ch;
bool tf = false;
string strtrimmed;
string strcheck;
strcheck.clear();
string strch;
l = printMenu(choice, header);
get->gotoxy(15, ++l);
int lastOptIndex = choice.size();
string sloi = std::to_string(lastOptIndex);
int lensloi = sloi.length();
strch.clear();
get->gotoxy(15, l);
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
for(int i = 0; i < w.ws_col; i++)
{
cout << " ";
}
get->gotoxy(15, l);
cout << "Enter Choice : ";
downline = l;
do
{
get->gotoxy(display + i, l);
ch = get->getche();
strcheck += ch;
i++;
tf = CString::trimfunc(&strcheck);
if(tf == false)
{
--i;
get->gotoxy(display + i, l);
continue;
}
if(tf == true && ch == ' ')
{
int len = strcheck.length();
get->gotoxy(display + len, l);
--i;
continue;
}
if( (int(ch) == 127) || (strcheck.length() > lensloi) || (int(ch) == 10) )
{
j = strcheck.length();
int m = j;
if(int(strcheck.at(--m)) == 10 )
{
strcheck.pop_back();
}
if( int(ch) == 127 )
{
strcheck.pop_back();
if(strcheck.length() > 0)
{
strcheck.pop_back();
i -= 2;
get->gotoxy(display + i, l);
cout << " ";
get->gotoxy(display + i, l);
}
else
{
i = 0;
}
continue;
}
if( strcheck.length() > lensloi )
{
strcheck.pop_back();
int sz = strcheck.length();
get->gotoxy(display + sz, l);
cout << " ";
get->gotoxy(display + sz, l);
--i;
continue;
}
tf = CValidator::intvalidator(strcheck);
if(tf == false)
{
strcheck.clear();
strch.clear();
i = 0;
get->gotoxy(display + 2, l);
cout << " -> invalid input, please correct it";
get->getch();
get->gotoxy(display, l);
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
for(int k = display; k < w.ws_col; k++)
{
cout << " ";
}
get->gotoxy(display, l);
continue;
}
else if (tf == true)
{
limit = CString::intChange(strcheck);
if( limit < 1 || limit > lastOptIndex )
{
strcheck.clear();
get->gotoxy(display + lensloi + 1, l);
cout << " -> outside of range, only between 1 to " << lastOptIndex;
get->getch();
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
get->gotoxy(display, l);
for(d = display; d < w.ws_col; d++)
{
get->gotoxy(d, l);
cout << " ";
}
get->gotoxy(display, l);
i = 0;
continue;
}
else if( int(ch) == 10)
{
optionChoice = std::atoi(strcheck.c_str());
}
}
}
}while(optionChoice < 1 || optionChoice > lastOptIndex );
lastLine = l + 1;
return optionChoice;
}
--------------------------------------------------------------------------
File : CQueue.h :-
------------------
#ifndef CQUEUE_H
#define CQUEUE_H
#include <clrscr-getch/clrscr-getch.h>
#include <validator/validator.h>
#include "CMenu.h"
#include "CVecMenu.h"
class CQueue
{
public:
CQueue();
virtual ~CQueue();
CQueue(const CQueue& other);
CQueue& operator=(const CQueue& other);
int getFunctionOfChoice();
protected:
private:
CMenu * menu;
CClrscrGetch *get;
CValidator *validator;
CVecMenu *vecmenu;
};
#endif // CQUEUE_H
--------------------------------------------------------------------------
File : CQueue.cpp :-
--------------------
#include "CQueue.h"
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::string;
CQueue::CQueue()
{
//ctor
menu = new CMenu;
get = new CClrscrGetch;
validator = new CValidator;
vecmenu = new CVecMenu;
}
CQueue::~CQueue()
{
//dtor
delete menu;
delete get;
delete validator;
delete vecmenu;
}
CQueue::CQueue(const CQueue& other)
{
//copy ctor
}
CQueue& CQueue::operator=(const CQueue& rhs)
{
if (this == &rhs) return *this; // handle self assignment
//assignment operator
return *this;
}
int CQueue::getFunctionOfChoice()
{
int choice;
do
{
get->clrscr();
int lastLine = 0;
int downline;
choice = menu->getChoice(vecmenu->queueMenu, "Queue Menu", lastLine);
downline = lastLine;
switch(choice)
{
case 1:
cout << " Sequential Queue as Linked List ";
get->getch();
break;
case 2:
cout << " Priority Queue ";
get->getch();
break;
case 3:
cout << " Circular Queue ";
get->getch();
break;
case 4:
cout << " Dequeue ";
get->getch();
break;
case 5:
break;
case 6:
get->clrscr();
exit(0);
}
}while(choice != 6 && choice != 5);
return 0;
}
--------------------------------------------------------------------------
File : CSorting.h :-
--------------------
#ifndef CSORTING_H
#define CSORTING_H
#include "CMenu.h"
#include "CVecMenu.h"
#include <iostream>
#include <clrscr-getch/clrscr-getch.h>
#include <validator/validator.h>
class CSorting
{
public:
CSorting();
virtual ~CSorting();
CSorting(const CSorting& other);
CSorting& operator=(const CSorting& other);
int getFunctionOfChoice();
protected:
private:
CMenu * menu;
CValidator * validator;
CClrscrGetch *get;
CVecMenu *vecmenu;
};
#endif // CSORTING_H
--------------------------------------------------------------------------
File : CSorting.cpp :-
----------------------
#include "CSorting.h"
#include <iostream>
using std::cout;
CSorting::CSorting()
{
//ctor
menu = new CMenu;
get = new CClrscrGetch;
validator = new CValidator;
vecmenu = new CVecMenu;
}
CSorting::~CSorting()
{
//dtor
delete menu;
delete get;
delete validator;
delete vecmenu;
}
CSorting::CSorting(const CSorting& other)
{
//copy ctor
}
CSorting& CSorting::operator=(const CSorting& rhs)
{
if (this == &rhs) return *this; // handle self assignment
//assignment operator
return *this;
}
int CSorting::getFunctionOfChoice()
{
int choice;
int lastLine;
do
{
get->clrscr();
choice = menu->getChoice(vecmenu->sortingMenu, "Sorting Menu", lastLine);
switch(choice)
{
case 1:
cout << "Bubble Sort";
get->getch();
break;
case 2:
cout << "Selection Sort";
get->getch();
break;
case 3:
cout << "Quick Sort";
get->getch();
break;
case 4:
cout << "Insertion Sort";
get->getch();
break;
case 5:
cout << "Binary Tree Sort";
get->getch();
break;
case 6:
cout << "Heap Sort";
get->getch();
break;
case 7:
cout << "Merge Sort";
get->getch();
break;
case 8 :
cout << "External Sort";
get->getch();
break;
case 9:
break;
case 10:
get->clrscr();
exit(0);
}
}while (choice != 9 && choice != 10);
return 0;
}
--------------------------------------------------------------------------
File : CStack.h :-
------------------
#ifndef CSTACK_H
#define CSTACK_H
#include "CMenu.h"
#include <iostream>
#include <clrscr-getch/clrscr-getch.h>
#include <validator/validator.h>
class CStack
{
public:
CStack();
virtual ~CStack();
CStack(const CStack& other);
CStack& operator=(const CStack& other);
int getFucitonOfChoice();
protected:
private:
CMenu *menu;
CValidator * validator;
CClrscrGetch *get;
};
#endif // CSTACK_H
--------------------------------------------------------------------------
File : CStack.cpp :-
--------------------
#include "CStack.h"
CStack::CStack()
{
//ctor
menu = new CMenu;
get = new CClrscrGetch;
validator = new CValidator;
}
CStack::~CStack()
{
//dtor
delete menu;
delete get;
delete validator;
}
CStack::CStack(const CStack& other)
{
//copy ctor
}
CStack& CStack::operator=(const CStack& rhs)
{
if (this == &rhs) return *this; // handle self assignment
//assignment operator
return *this;
}
int CStack::getFucitonOfChoice()
{
int choice;
// do
// {
// chioce = menu->getChoice(menu->)
// switch(choice)
// {
// }
//
// }while()
return 0;
}
--------------------------------------------------------------------------
File : CString.h :-
-------------------
#ifndef CSTRING_H
#define CSTRING_H
#include <string>
#include <iostream>
class CString
{
public:
CString();
virtual ~CString();
CString(const CString& other);
CString& operator=(const CString& other);
static bool trimfunc(std::string *str);
static int intChange(std::string str);
protected:
private:
};
#endif // CSTRING_H
--------------------------------------------------------------------------
File : CString.cpp :-
---------------------
#include "CString.h"
using std::cin;
using std::cout;
using std::endl;
using std::string;
CString::CString()
{
//ctor
}
CString::~CString()
{
//dtor
}
CString::CString(const CString& other)
{
//copy ctor
}
CString& CString::operator=(const CString& rhs)
{
if (this == &rhs) return *this; // handle self assignment
//assignment operator
return *this;
}
bool CString::trimfunc(string *str2)
{
int atstart = 0, atend = -1;
string str;
if(str2->length() != 0)
{
str = *str2;
}
else
{
return false;
}
for(int i = 0; i < str.size(); i++)
{
if(str[i] != ' ')
{
atstart = i;
break;
}
}
for(int i = str.size()-1; i >= 0; i--)
{
if(str[i] != ' ')
{
atend = i;
break;
}
}
str2->clear();
for(int i = atstart; i <= atend; i++)
{
*str2 += str[i];
}
if(str2->length() == 0)
{
return false;
}
return true;
}
int CString::intChange(string str)
{
int i = std::atoi(str.c_str());
return i;
}
--------------------------------------------------------------------------
--------------------------------------------------------------------------











