When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
6 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
@heady spade
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
this is the code but I forgot to add a coment before sending it #include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cwchar>
int main() {
const wchar_t* inputFile = L"input.txt";
const wchar_t* outputFile = L"output.txt";
// Open files with _wfopen
FILE* inFile = _wfopen(inputFile, L"r, ccs=UTF-8"); // Read mode, UTF-8 encoding
FILE* outFile = _wfopen(outputFile, L"w, ccs=UTF-8"); // Write mode, UTF-8 encoding
if (!inFile) {
std::wcerr << L"Error: Unable to open file " << inputFile << L"\n";
return 1;
}
if (!outFile) {
std::wcerr << L"Error: Unable to open file " << outputFile << L"\n";
fclose(inFile); // Clean up the input file
return 1;
}
std::wstring word;
std::vector<std::wstring> words;
wchar_t buffer[256]; // Buffer to read wide characters
while (fwscanf(inFile, L"%255ls", buffer) == 1) { // Read word into buffer
word = buffer;
// Modify the word: Replace 'm' with 'j'
for (size_t i = 0; i < word.length(); i++) {
//This I want to add a switch for all the symbols but first wanna make sure it works
if (word[i] == L'm') {
word[i] = L'j';
}
}
words.push_back(word); // Store modified word
fwprintf(outFile, L"%ls ", word.c_str()); // Write modified word to output file
}
fclose(inFile);
fclose(outFile);
// Display processed words
std::wcout << L"Processed words:\n";
for (const std::wstring& w : words) {
std::wcout << w << L"\n";
}
return 0;
}
```c
int main() {}
```
int main() {}
Oh, by the way, this is the wrong channel (this is for C), you want #1013107104678162544