初心者の質問相談にやさしく答えるスレ Part15 (611レス)
前次1-
抽出解除 必死チェッカー(本家) (べ) 自ID レス栞 あぼーん

リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
201
(1): 2024/02/15(木)14:53 ID:P1Y+id6u(1/7) AAS
>>200
頑なに出さないからね
無視で良いと思うよ
209: 2024/02/15(木)15:15 ID:P1Y+id6u(2/7) AAS
>>203
ブートローダーはwindowsブートローダーを使いたいのかgrubを使いたいのか
パーティションテーブルがMBRなのかGPTなのか
MBRならプライマリーは何個あるのか
UEFI+GPTならESPの容量に余裕はあるのか
diskpartのコマンド結果とか

ちょっと前にも書いたけど本気で解決したいと思ってるなら出せる情報全部出せばいい
それすら出来ないの?

Man爺と同類か?
215: 2024/02/15(木)18:44 ID:P1Y+id6u(3/7) AAS
>>213
chatGPT

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

std::string execCmd(const char* cmd) {
std::string result;
FILE* pipe = popen(cmd, "r");
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
char buffer[128];
while (!feof(pipe)) {
if (fgets(buffer, 128, pipe) != NULL) {
result += buffer;
}
}
pclose(pipe);
return result;
}
216: 2024/02/15(木)18:45 ID:P1Y+id6u(4/7) AAS
int main(int argc, char *argv[]) {
if (argc != 5) {
std::cerr << "Usage: " << argv[0] << " <input_file> <output_file> <command> <target_string>" << std::endl;
return 1;
}

std::string inputFile = argv[1];
std::string outputFile = argv[2];
std::string command = argv[3];
std::string targetString = argv[4];

// Execute the command
std::string result = execCmd(command.c_str());

std::ifstream inFile(inputFile);
if (!inFile) {
std::cerr << "Error: Cannot open input file." << std::endl;
return 1;
}

std::ofstream outFile(outputFile);
if (!outFile) {
std::cerr << "Error: Cannot create output file." << std::endl;
return 1;
}
217: 2024/02/15(木)18:45 ID:P1Y+id6u(5/7) AAS
std::string line;
bool found = false;
while (std::getline(inFile, line)) {
size_t pos = line.find(targetString);
if (pos != std::string::npos) {
outFile << line.substr(0, pos) << result << line.substr(pos) << std::endl;
found = true;
} else {
outFile << line << std::endl;
}
}

inFile.close();
outFile.close();

if (!found) {
std::cerr << "Error: Target string not found in input file." << std::endl;
return 1;
}

std::cout << "File edited successfully." << std::endl;

return 0;
}
218: 2024/02/15(木)18:47 ID:P1Y+id6u(6/7) AAS
ビルド
g++ -o edit_file edit_file.cpp
使い方
./edit_file example.txt edited_example.txt "seq 10" "END"
219
(1): 2024/02/15(木)18:52 ID:P1Y+id6u(7/7) AAS
因みに3.5の無料版の方だから動くかどうかは分かりません
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ

ぬこの手 ぬこTOP 0.033s