#include <iostream>
#include <string>
#include <Windows.h>
#include <fstream>
#include <sstream>
#include <signal.h>
#include <io.h>
#include <vector>
#include <process.h>
#include <cstdio>
#include <assert.h>
#pragma warning(disable : 4996)
using namespace std;
using std::string;
using std::ifstream;
using std::istream;
string BUF;
string DestMAC;
//strFind是你查找的字符串
//strBuffer是返回的所在行
string FindString(string strFind, string& strBuffer)
{
ifstream fTestTxt(("mac12.csv")); //the path of the file which you want to search
char oneLineBuffer[1024]; //one line has as many as 1024 character
while (fTestTxt.getline(oneLineBuffer, 1024))
{
string strTemp(oneLineBuffer);
if (string::npos != strTemp.find(strFind.c_str())) //find it
{
strBuffer = strTemp; //return buffer
//cout << strTemp << endl;
//cout << strBuffer << endl;
return strBuffer;
}
}
return false;
}
int main() {
cout << "please in put MAC" << endl;
cin >> DestMAC;
BUF=FindString("00409DE066CB", BUF);
cout << BUF;
return 0;
}
标签:文本,return,cout,查找,字符串,using,include,strBuffer,string From: https://www.cnblogs.com/wang-xiao-shuai/p/17408592.html