C++ 字符串string、字符char、宽字符数组wstring、宽字符wchar_t互相转换(2021.4.20)

article/2025/10/15 9:24:59

C++单字符串和宽字符串学习 2021.4.20

  • 1、char 和 string
    • 1.1 单字符 char
    • 1.2 单字符数组 char[] 和 char*
      • 1.2.1 char[]
      • 1.2.2 char*
    • 1.3 单字符串 string
    • 1.4 char[] 转 string
    • 1.5 cha[] 转char*
    • 1.6 string 转 char*
    • 1.7 string 转 char[]
  • 2、wchar_t 和 wstring
    • 2.1 宽字符 wchar_t
    • 2.2 宽字符数组 wchar_t[] 和 wchar_t*
      • 2.2.1 wchar_t[]
      • 2.2.2 wchar_t*
    • 2.3 宽字符串 wstring
    • 2.4 wchar_t[] 转 wstring
    • 2.5 wchar_t[] 转 wchar_t*
    • 2.6 wstring 转 wchar_t[]
    • 2.7 wstring 转 wchar_t*
  • 3、string与wstring互相转换
    • 3.1 string 转 wstring
    • 3.2 wstring 转 string
    • 3.3 wchar_t * 转char *
    • 3.4 wchar_t 转char *

1、char 和 string

1.1 单字符 char

        单字符通常都是只占用一个字节存储的字符,包括数字、大小写英文字母和一些常用标点符号等,其中’\n’为换行符,’\0’为字符串结束符,其对应的ASCII吗值为0,’\r’为回车符,’\t’为制表符。

#include <iostream>
using namespace std;
int main()
{char char_a = '1';int number_a = char_a - '0';//可通过-'0'判断是否为数字字符while (true){cout << "请输入单个字符:";cin >> char_a;cout << "您输入的字符为: " << char_a << endl;if (char_a - '0' >= 0 && char_a - '0' <= 9)cout << char_a << " 为数字字符!" << endl;else if (char_a >= 65 && char_a <= 90)cout << char_a << " 为大写英文字母!" << endl;else if (char_a >= 97 && char_a <= 122)cout << char_a << " 为小写英文字母!" << endl;}system("pause");return 0;
}

在这里插入图片描述

1.2 单字符数组 char[] 和 char*

        多个单字符就可以构成一定长度的字符串,而字符串可以用字符数组char[]来存储,char * 也可以来存储字符串数组,但通常char * 用来遍历char[]中的所有字符。

1.2.1 char[]

#include <iostream>
using namespace std;
int main()
{char a[] = {'a','b','1','5','P','\0'};//'\0'为字符串结束符,可通过它来获取字符串的长度int length = 0;while (a[length] != '\0')length++;cout << "字符串\"" << a << "\"的长度为" << length << endl;cout << "请输入" << length << "个字符:";for (int i = 0; i < length; i++)cin >> a[i];cout << "修改后的字符串为:" << a << endl;char  str[12] = {"hello world"};system("pause");return 0;
}

在这里插入图片描述

1.2.2 char*

#include <iostream>
using namespace std;
int main()
{char str[12] = {"hello world"};//char str[] = { "hello world" };//不设置长度也可以char *a = str;//通过常量字符串来初始化int length = 0;while (a[length] != '\0')length++;cout << "字符串\"" << a << "\"的长度为" << length << endl;cout << "请输入" << length << "个字符:";for (int i = 0; i < length; i++)cin >> a[i];cout << "修改后的字符串为:";for (int i = 0; i < length; i++)cout << a[i];cout << endl;system("pause");return 0;
}

在这里插入图片描述

1.3 单字符串 string

#include <iostream>
#include <string>
using namespace std;
int main()
{string str1 = "ABCEdrt124abR";cout << str1 << endl;int length = 0;while (str1[length] != '\0')length++;cout << "字符串\"" << str1 << "\"的长度为" << length << endl;cout << "请输入" << length << "个字符:";for (int i = 0; i < length; i++)cin >> str1[i];cout << "修改后的字符串为:" <<str1<< endl;string str2 = "9GtR56Erlbsgfs";string str = str1 + str2;//字符串连接成一个字符串cout << "连接后的字符串为:" << str << endl;system("pause");return 0;
}

在这里插入图片描述

1.4 char[] 转 string

string char_arrayTostring(char a[])//字符数组char[]转string函数
{string s = "";int j = 0;while (a[j] != '\0')s += a[j++];return s;
}

1.5 cha[] 转char*

char str[] = { "Hello My Computer" };//不设置长度也可以
char *a = str;//通过常量字符串来初始化
int length = 0;
while (a[length] != '\0')length++;
cout << "字符串\"" << a << "\"的长度为" << length << endl;
for (int i = 0; i < length; i++)cout << a[i];
cout << endl;

1.6 string 转 char*

string str_string = "AFDSDSFS8345otsdgf";
char *c;
c = &str_string[0];
while (*c != '\0')
{cout << *c;c++;
}
cout << endl;

1.7 string 转 char[]

string str = "ABCDEFG";
char a[20];
strcpy_s(a, str.c_str());//用到 c_str()函数
int length = 0;
while (a[length] != '\0')length++;
cout << "字符串\"" << a << "\"的长度为" << length << endl;
for (int i = 0; i < length; i++)cout << a[i];
cout << endl;

2、wchar_t 和 wstring

2.1 宽字符 wchar_t

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wchar_t han = L'汉', zi = L'字';//以单个汉字的方式给unicode中文字符赋值cout << han << "  " << zi << " " << endl;//输出中文字符对应的十进制数wcout << han << "  " << zi << " " << endl;//输出中文字符wchar_t mychar1 = 055527;//以八进制数字给unicode中文字符赋值cout << mychar1 << "  ";wcout << mychar1 << endl;mychar1 = 23383;//以十进制数字给unicode中文字符赋值cout << mychar1 << "  ";wcout << mychar1 << endl;mychar1 = 0x5b57;//以十六进制数字给unicode中文字符赋值cout << mychar1 << "  ";wcout << mychar1 << endl;wcout << mychar1;cout << "对应的十六进制、十进制和八进制数分别为:" << showbase << hex << mychar1 << " " << showbase << dec << mychar1 << " " << showbase << oct << mychar1 << endl;wchar_t a = L'中';wcout << a<<'\n';cout << "请输入一个宽字符的汉字:";wcin >> a;cout << "您输入的宽字符汉字:";wcout << a;cout <<"对应的十六进制、十进制和八进制数分别为:" << showbase << hex << a << " " << showbase << dec << a << " " << showbase << oct << a << endl;system("pause");return 0;
}

在这里插入图片描述

2.2 宽字符数组 wchar_t[] 和 wchar_t*

2.2.1 wchar_t[]

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wchar_t test[] = L"中国梦必胜";//wchar_t test[] = { L'我',L'是',L'中',L'国',L'人',L'\0' };//第二种初始化方式cout << test << "  " << endl;wcout << test << "  " << endl;int len = 0;while (test[len] != L'\0')len++;for (int i = 0; i < len; i++){cout << test[i] << " ";wcout << test[i] << endl;}cout <<"长度为:"<< len << endl;cout << "系统自带函数统计长度为:" << wcslen(test) << endl;cout << "请重新输入" << len << "个汉字修改上面的字符串:";for (int i = 0; i < len; i++)wcin >> test[i];cout << "修改后的字符串:";wcout << test << endl;//第三种初始化方式cout << "请输入8个汉字:";wchar_t s[]=L" ";int i = 0;for (;i < 8; i++){wcin >> s[i];}wcout << s;cout << endl;system("pause");return 0;
}

在这里插入图片描述

2.2.2 wchar_t*

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wchar_t test1[] = L"中国梦必胜";wchar_t* test = test1;cout << test << "  " << endl;wcout << test << "  " << endl;int len = 0;while (test[len] != L'\0')len++;for (int i = 0; i < len; i++){cout << test[i] << " ";wcout << test[i] << endl;}cout <<"长度为:"<< len << endl;cout << "系统自带函数统计长度为:" << wcslen(test) << endl;cout << "请重新输入" << len << "个汉字修改上面的字符串:";for (int i = 0; i < len; i++)wcin >> test[i];cout << "修改后的字符串:";wcout << test<< endl;system("pause");return 0;
}

在这里插入图片描述

2.3 宽字符串 wstring

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wstring wst = { L'我',L'是',L'中',L'国',L'人',L'\0' };int len = 0;while (wst[len] != L'\0')len++;wcout << wst;cout <<"长度为:"<< len << endl;cout << "请重新输入" << len << "个汉字修改上面的字符串:";for (int i = 0; i < len; i++)wcin >> wst[i];cout << "修改后的字符串:";wcout << wst << endl;wchar_t ch1[] = L"中国人";//宽字符数组std::wstring wstr(ch1);wcout << wstr << endl;system("pause");return 0;
}

在这里插入图片描述

2.4 wchar_t[] 转 wstring

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;wstring wchart_arrayTowstring(wchar_t a[])
{wstring wstr=L"";int j = 0;while (a[j] != L'\0'){wstr += a[j];j++;}return wstr;
}
int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wchar_t test1[] = L"中国推动世界和平";wstring wstr1 = wchart_arrayTowstring(test1);wcout << wstr1<< endl;int len = 0;while (wstr1[len] != '\0')len++;cout << "请输入" << len << "个汉字来修改字符串:";for (int i = 0; i < len; i++)wcin >> wstr1[i];wcout << wstr1 << "  " << endl;system("pause");return 0;
}

在这里插入图片描述

2.5 wchar_t[] 转 wchar_t*

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wchar_t test1[] = L"中国推动世界和平";wchar_t* test = test1;wcout << test<< endl;int len = 0;while (test[len] != '\0')len++;cout << "请输入" << len << "个汉字来修改字符串:";for (int i = 0; i < len; i++)wcin >> test[i];wcout << test << "  " << endl;system("pause");return 0;
}

在这里插入图片描述

2.6 wstring 转 wchar_t[]

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wstring str = L"有一个强大的祖国在身后";wchar_t a[20];int length = 0;while (str[length] != '\0')length++;cout << "字符串\"";wcout << str;cout<< "\"的长度为" << length << endl;for (int i = 0; i < length; i++)a[i] = str[i];wcout << a;cout << endl;system("pause");return 0;
}

在这里插入图片描述

2.7 wstring 转 wchar_t*

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wstring str = L"有一个强大的祖国在身后";wchar_t *a= &str[0];int length = 0;while (a[length] != '\0')length++;cout << "字符串\"";wcout << a;cout<< "\"的长度为" << length << endl;system("pause");return 0;
}

在这里插入图片描述

3、string与wstring互相转换

3.1 string 转 wstring

        MultiByteToWideChar()该函数映射一个字符串到一个宽字符(unicode)的字符串,将单字符组成的多字节string转换为宽字符串wstring,则需要利用系统自带的MultiByteToWideChar()函数进行转换。

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;wstring stringTowstring(string str)
{int len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);if (len == 0)return wstring(L"");wchar_t* wct = new wchar_t[len];if (!wct)return std::wstring(L"");MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, wct, len);wstring wstr(wct);delete[] wct;wct = NULL;return wstr;
}
int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式string s = "有一个强大的祖国在身后";wstring a = stringTowstring(s);int length = 0;while (a[length] != L'\0')length++;cout << "字符串\"";wcout << a;cout<< "\"的长度为" << length << endl;system("pause");return 0;
}

在这里插入图片描述

3.2 wstring 转 string

        WideCharToMultiByte()该函数可以映射一个unicode字符串到一个多字节字符串,执行转换的代码页、接收转换字符串、允许额外的控制等操作。将宽字符串转换多个单字符组成的字符串,则需要利用WideCharToMultiByte()函数进行转换。

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;string wstringTostring(wstring wstr)
{int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL);if (len == 0)return string("");char* psz = new char[len];if (!psz)return string("");WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, psz, len, NULL, NULL);string str(psz);delete[] psz;psz = NULL;return str;
}int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wstring s = L"有一个强大的祖国在身后";string a = wstringTostring(s);int length = 0;while (a[length] != '\0')length++;cout << "字符串\""<< a << "\"的长度为" << length << endl;system("pause");return 0;
}

在这里插入图片描述

3.3 wchar_t * 转char *

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;char* pwchartTopchar(wchar_t* pwcstr)
{int size = WideCharToMultiByte(CP_OEMCP, 0, pwcstr, wcslen(pwcstr), NULL, 0, NULL, NULL);	//第一次调用确认转换后单字节字符串的长度,用于开辟空间char* pcstr = new char[size + 1];WideCharToMultiByte(CP_OEMCP, 0, pwcstr, wcslen(pwcstr), pcstr, size, NULL, NULL);	//第二次调用将双字节字符串转换成单字节字符串pcstr[size] = '\0';return pcstr;	//string pKey = pCStrKey;可以转换为string字符串
}
int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wchar_t *wcstr = L"我们都有一个家";char *a = pwchartTopchar(wcstr);int length = 0;while (a[length] != '\0')length++;cout << "字符串\""<< a << "\"的长度为" << length << endl;system("pause");return 0;
}

在这里插入图片描述

3.4 wchar_t 转char *

#include <iostream>
#include<string>
#include <windows.h>  //这个头文件必须添加
#include <iomanip>
#include <fstream>
using namespace std;char* wcharTopchar(wchar_t wchar)
{wchar_t* pwchar = &wchar;int size = WideCharToMultiByte(CP_OEMCP, 0, pwchar, wcslen(pwchar), NULL, 0, NULL, NULL);char* pchar = new char[size + 1];WideCharToMultiByte(CP_OEMCP, 0, pwchar, wcslen(pwchar), pchar, size, NULL, NULL);pchar[size] = '\0';return pchar;
}
int main()
{wcin.imbue(std::locale("chs"));//载入中文字符输入方式wcout.imbue(std::locale("chs"));//载入中文字符输入方式wchar_t wcstr = L'家';char *a = wcharTopchar(wcstr);int length = 0;while (a[length] != '\0')length++;cout << "字符串\""<< a << "\"的长度为" << length << endl;system("pause");return 0;
}

在这里插入图片描述


http://chatgpt.dhexx.cn/article/RfwCpsQw.shtml

相关文章

string和wstring相互转换以及wstring显示中文问题

如果你只是使用C来处理字符串&#xff0c;会用到string。不过string是窄字符串ASCII&#xff0c;而很多Windows API函数用的是宽字符Unicode。这样让string难以应对。作为中国的程序员&#xff0c;我们第一个想到的字符串就是中文&#xff0c;而不是英文。所以经常会遇到中文字…

C++里面,什么时候使用std::wstring

看你要使用什么字符编码了&#xff0c; std::wstring主要用于 UTF-16编码的字符,而std::string主要用于存储单字节的字符( ASCII字符集 )&#xff0c;但是也可以用来保存UTF-8编码的字符。&#xff08;UTF-8和UTF-16是UNICODE字符集的两种不同的字符编码&#xff09; 如果你的…

String类与wstring类的区别

String类与wstring类的区别 本质区别 存储字符的区别 #include <iostream> #include <string> using namespace std; int main() { wstring wstr1 L"你好世界"; // L普通字符串 宽字符串 const wchar_t *ch1 wstr1.c_str(); // 转化为宽字符…

从新建工程开始使用C++开发单片机(以STM32为例):七、移植Arduino的WString(附代码)

在上一篇文章中&#xff0c;介绍了outputString和inputString&#xff0c;其中所运用到的字符串类型String也是C驱动层中功能强大且重要的一个类。这个类移植自Arduino的WString。这篇文章将会展示WString的易用性&#xff0c;并且从编译输出后程序大小的角度比较WSting和C std…

0005:Qt常用类 - QDateTime

Qt常用类 - QDateTime 1 开发环境 在介绍内容之前&#xff0c;先说明一下开发环境&#xff0c;如下图&#xff1a; Qt版本&#xff1a;Qt5.3.2&#xff1b; Qt开发工具&#xff1a;Qt Creater 3.2.1&#xff1b; Qt构建工具&#xff1a;Desktop Qt 5.3 MinGW 32bit&#xff…

QDateTime的11种显示方式

QDateTime datetime QDateTime::currentDateTime(); datetime.toString(“hh:mm:ss\nyyyy/MM/dd”); datetime.toString(“hh:mm:ss ap\nyyyy/MM/dd”); datetime.toString(“hh:mm:ss\nyyyy-MM-dd”); datetime.toString(“hh:mm:ss ap\nyyyy-MM-dd”); datetime.to…

70 QDateTime时间戳转换有误

1 前言 在开发工具中需要用时间戳转换成格式化时间来显示&#xff0c;但引用QT中自带的时间类QDateTime转换时&#xff0c;发现转换时间有误问题&#xff0c;转换的结果时分秒是正确的&#xff0c;但月份确实错误的。因此在未深入研究qt实现情况下&#xff0c;需要得到正确的格…

QDateTime类的部分函数使用解析

QDateTime类提供了日期和时间功能。 QDateTime对象包含一个日历日期和一个时钟时间&#xff08;一个“日期时间”&#xff09;。它是QDate和QTime两个类的组合。它可以从系统时钟中读取当前日期时间。它提供比较日期时间和操作日期时间的函数&#xff0c;比如加上一定数量的秒…

QDateTime时间相减

qDebug()<<"span"<<QDateTime::fromMSecsSinceEpoch(QDateTime::currentDateTime().toMSecsSinceEpoch() - time.toMSecsSinceEpoch()).toUTC().toString("hh:mm:ss"); 1、使用 QDateTime::toMSecsSinceEpoch 计算时间差&#xff1b; 2、使用…

小心 QDateTime

QDateTime 时间跳变问题接收服务端时间问题 时间跳变问题 QDateTime的具体用法可以在Qt creator 鼠标双击选中&#xff0c;按 F1 查看它的文档, Qt 的文档还是不错的. 我们有时会用下面的代码来做等待, 在笔者使用过程中发现 //等待QDateTime n QDateTime::currentDateTime(…

QDateTime

一、描述 QDateTime 对象对日历日期和时钟时间进行编码。它结合了 QDate 和 QTime 类的特性。它可以从系统时钟中读取当前日期时间。它提供了用于比较日期时间和通过添加秒数、天数、月数或年数来操作日期时间的函数。 二、成员函数 1、QString toString(const QString &…

QDateTime、QTime获取当前时间

1、引用头文件 #include #include 2、显示当前时间 ui->label->setText(“QDateTime:\nCurrent Time is:” QDateTime::currentDateTime().toString(“yyyy-MM-dd hh:mm:ss ddd”)); ui->label->setText(ui->label->text() "\n\nQTime:\nHour mi…

通过图像修复的视觉提示

Visual Prompting via Image Inpainting 目录 总结 一、Introduction 二、Visual Prompting via Image Inpainting 1. Inpainting using MAE-VQGAN 2. Prompting Inpainting Models 3. The Computer Vision Figures Dataset 三、Experiments and Results 四、Discussio…

图像修复必读的10篇论文

点击上方“AI公园”&#xff0c;关注公众号&#xff0c;选择加“星标“或“置顶” 因公众号更改了推送规则&#xff0c;记得读完点“在看”~下次AI公园的新文章就能及时出现在您的订阅列表中 作者&#xff1a;Chu-Tak Li 编译&#xff1a;ronghuaiyang 导读 这10篇文章给出了图…

【图像修复】论文阅读笔记 ----- 《Image inpainting based on deep learning: A review》

文章目录 原文下载地址概述**单阶段修复****单结果修复****多元修复方法** **渐进图像修复**低分辨率图像修复高分辨率图像修复 基于先验知识的修复轮廓边缘引导图像修复生成性先验引导图像修复 用于图像修复的数据集**不规则掩模数据集&#xff1a;****图像修复数据集&#xf…

毕业设计之 - 基于深度学的图像修复 图像补全

1 前言 Hi&#xff0c;大家好&#xff0c;这里是丹成学长&#xff0c;今天向大家介绍 基于深度学的图像修复 图像补全 大家可用于 毕业设计 2 什么是图像内容填充修复 内容识别填充(译注: Content-aware fill ,是 photoshop 的一个功能)是一个强大的工具&#xff0c;设计师…

基于GAN的图像修复--论文笔记

文献下载看下载处或评论链接 /1 Region Normalization for Image Inpainting 主要内容&#xff1a;将损坏的图像输入到神经网络中可能会产生问题&#xff0c;例如无效像素的卷积、归一化的均值和方差。但是&#xff0c;当前方法无法解决网络中的均值和方差漂移问题。当前方…

图像修复文章汇总

图像修复技术的研究是计算机视觉以及计算机图形学的一个具有重大意义的研究课题。对于带有损失区域的图像&#xff0c;由于我们并不知道原本图像的具体形式&#xff0c;我们只能类似于“凭空捏造”一些像素去填补这种缺失。正因如此&#xff0c;图像修复实际是根据人类自己的视…

图像算法原理与实践——图像修复之 全变分模型

在图像算法的高层次处理中&#xff0c;有一类很典型的应用&#xff0c;就是图像修复算法。图像在采集、传输、预处理过程中&#xff0c;都可能会发生图像数据被修改、损失和缺失等问题&#xff08;例如&#xff1a;部分图像内容被污染、雾霾等&#xff09;&#xff0c;另外&…

图像修复序列——BSCB模型

1. 参考文献 2. BSCB模型代码 2.1 BSCB模型demo % demo_BSCB.m % Author: HSW % Date: 2015/3/25 % HARBIN INSTITUTE OF TECHNOLOGY % % set matlab close all; clear all; clc;options.null 0; % read image Img imread(Image\butterfly.bmp); Img imread(Image\peppers…