|
thanks,I got to the point of searching input and limiting it to 10 characters but I dont know how to replace that searched words.
modified 19-Jul-24 2:59am.
|
|
|
|
|
And? What have you tried?
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
#include <stdio.h>
#include <string.h>
#define MAX_STRINGS 3
#define MAX_LENGTH 512
void searchAndReplace(char text[][MAX_LENGTH], int numStrings, const char* searchStr, const char* replaceStr) {
int replaced = 0;
for (int i = 0; i < numStrings; ++i) {
char buffer[MAX_LENGTH];
char* pos;
size_t searchLen = strlen(searchStr);
size_t replaceLen = strlen(replaceStr);
strcpy_s(buffer, text[i]);
while ((pos = strstr(buffer, searchStr)) != NULL) {
if (!replaced) {
printf("%s\n", text[i]);
replaced = 1;
}
size_t len = strlen(pos + searchLen);
memmove(pos + replaceLen, pos + searchLen, len + 1);
memcpy(pos, replaceStr, replaceLen);
}
if (replaced) {
printf("%s\n", buffer);
replaced = 0; }
}
}
int main() {
char strings[MAX_STRINGS][MAX_LENGTH] = {
"18歳と81歳の違い。18歳は恋に溺れる人で、81歳はお風呂に溺れる人。18歳は道を走り、逆もまた然り。81歳の人が走っている。18歳は心がもろく、81歳は骨がもろい。私は18歳で心臓が止まらない。",
"81歳の彼は飛行機を止められない。18歳は恋に窒息することができ、81歳は餅に窒息することができる。偏差値が気になる。私は18歳で、81歳で血圧と血糖値を気にしている。まだ何も知らない18歳、もう何も覚えていない81歳。",
"自分を探している18歳と、みんなを探している81歳。"
};
printf("Original strings:\n");
for (int i = 0; i < MAX_STRINGS; ++i) {
printf("%s\n", strings[i]);
}
char searchStr[11], replaceStr[11];
printf("Enter search string (up to 10 characters): ");
fgets(searchStr, sizeof(searchStr), stdin);
searchStr[strcspn(searchStr, "\n")] = '\0'; printf("Enter replacement string (up to 10 characters): ");
fgets(replaceStr, sizeof(replaceStr), stdin);
replaceStr[strcspn(replaceStr, "\n")] = '\0';
if (strlen(searchStr) > 10 || strlen(replaceStr) > 10) {
fprintf(stderr, "Search and replacement strings must be up to 10 characters long.\n");
return 1;
}
int found = 0;
for (int i = 0; i < MAX_STRINGS; ++i) {
if (strstr(strings[i], searchStr) != NULL) {
found = 1;
searchAndReplace(strings, MAX_STRINGS, searchStr, replaceStr);
}
}
if (!found) {
printf("Nothing is changed.\n");
}
return 0;
}
this is best one I tried and it does not replace the words on the original string.
[edit]
OriginalGriff: code block added
[/edit]
modified 19-Jul-24 3:37am.
|
|
|
|
|
Why not? What did the debugger show you was happening?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
the debugger let me input my search string and not letting me enter my replacement string. I made it so that 10 letters can be enter into it but it stop working when I put letters over 3. Are there any chance the program is mistaking one japanese word into 3 letters?
|
|
|
|
|
Assuming that your Japanese is in Unicode (Hiragana / Katakana) then it'll usually be 2 bytes per character, but it is possible to use three byte Unicode (since the possible range is 21 bits, meaning 3 bytes)
What exactly do you mean "not letting me enter my replacement string." I'm pretty sure it didn't try to smack your wrist and tell you off but what exactly did happen? How did you check?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
char on it's own is 1 byte - for Unicode you probably need to use the uchar.h header and its' types, but I've never needed them so I can't help you that much. You might want to check your course notes and Google before going any further.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Member 16311074 wrote: ...not letting me enter my replacement string. Try changing the size of searchStr and replaceStr to something too large (but still only enter 10 characters). When you make them just large enough and you enter in that many characters, fgets() leaves the \n in the keyboard buffer and the second call to fgets() see it and exits right away.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
First run:
~~~~~~~~~~~~~~~~
Original strings:
18歳と81歳の違い。18歳は恋に溺れる人で、81歳はお風呂に溺れる人。18歳は道を走り、逆もまた然り。81歳の人が走っている。18歳は心がもろく、81歳は骨がもろい。私は18歳で心臓が止まらない。
81歳の彼は飛行機を止められない。18歳は恋に窒息することができ、81歳は餅に窒息することができる。偏差値が気になる。私は18歳で、81歳で血圧と血糖値を気にしている。まだ何も知らない18歳、もう何も覚えていない81歳。
自分を探している18歳と、みんなを探している81歳。
Enter search string (up to 10 characters): 2
Enter replacement string (up to 10 characters): #
Nothing is changed.
Second run:
~~~~~~~~~~~
Original strings:
18歳と81歳の違い。18歳は恋に溺れる人で、81歳はお風呂に溺れる人。18歳は道を走り、逆もまた然り。81歳の人が走っている。18歳は心がもろく、81歳は骨がもろい。私は18歳で心臓が止まらない。
81歳の彼は飛行機を止められない。18歳は恋に窒息することができ、81歳は餅に窒息することができる。偏差値が気になる。私は18歳で、81歳で血圧と血糖値を気にしている。まだ何も知らない18歳、もう何も覚えていない81歳。
自分を探している18歳と、みんなを探している81歳。
Enter search string (up to 10 characters): πéèπ
Enter replacement string (up to 10 characters): ----
18歳と81歳の違い。18歳は恋に溺れる人で、81歳はお風呂に溺れる人。18歳は道を走り、逆もまた然り。81歳の人が走っている。18歳は心がもろく、81歳は骨がもろい。私は18歳で心臓が止まらない。
∩╝æ∩╝ÿµ¡│πü¿∩╝ÿ∩╝浡│πü«ΘüòπüäπÇé∩╝æ∩╝ÿµ¡│πü»µüïπü½µ║║πéîπéïΣ║║πüºπÇü∩╝ÿ∩╝浡│πü»πüèΘó¿σæéπü½µ║║πéîπéïΣ║║πÇé∩╝æ∩╝ÿµ¡│πü»ΘüôπéÆΦ╡░----ÇüΘÇåπééπü╛πüƒτä╢----Çé∩╝ÿ∩╝浡│πü«Σ║║πüîΦ╡░πüúπüªπüäπéïπÇé∩╝æ∩╝ÿµ¡│πü»σ┐âπüîπééπéìπüÅπÇü∩╝ÿ∩╝浡│πü»Θ¬¿πüîπééπéìπüäπÇéτºüπü»∩╝æ∩╝ÿµ¡│πüºσ┐âΦçôπüóπü╛πéëπü¬πüäπÇé
Seems to be running as expected here.
|
|
|
|
|
Member 16311074 wrote: replaced = 0; // Reset for the next string Since replaced is a local variable (and searchAndReplace() is not static ), this statement does nothing useful. This has nothing to do with your overall issue, though.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Does anyone know the use of QueryChangesVirtualDisk ?
I have call the function successfully.
But how to use the QUERY_CHANGES_VIRTUAL_DISK_RANGE?
|
|
|
|
|
|
the offset is the position of VirtualDisk or the position of vhdx file?
in vSphere, the offset is the position of VirtualDisk (flat vmdk).
|
|
|
|
|
It's the offset into the disk in bytes, not the file representing it.
|
|
|
|
|
|
Dear somebody,
I have in trouble with some code.
Q1) ==> Actually my reqeust.
I want to build this open source "https://github.com/ChengranAA/QuickNii" but something failed in
nifticlib and zlib. The owner maybe not familiar with Windows build.
So I've found new ones.
https:
For windows git bash method...
https:
this man tells original Windows CMake method but...
I'm already exhausted in CMake gui use!!!!
Is there anybody who can help EASY&Simple~~ Windows develop source code view????
I want to change it but...there some problems and not clean changed~
For the
Q2) C# wpf code can wrap(import code) well the C++ codes in VS2022?? (Just for usual programming)
If this question is stupid or something violated codeproject policy, I will delete it or I will
agree to automatically delete from codeproject admin.
|
|
|
|
|
You'll probably have to do this manually.
Create an Visual Studio solution, add the files.
Clone and build the dependencies, hope they have a Windows build somewhere.
imgui should build on Windows; same for implot.
don't know about the other NIFTI library; but it's C library, it should be easy to port.
Good luck.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
Okay..
I've already recognized that.
But I've tried that more than 5 times.
But hard for me to make clean & no error Windows code.
Is there anybody who can help to change code for me?
If somebody can do it, I will send my mail address.
|
|
|
|
|
It doesn't work like that.
There are plenty of sites where you can hire someone to do your work for you. This is not one of them.
We're happy to help with specific problems in code you have written. But this is not a "do my work for me" or a "convert this code for me" type of site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Can someone please tell me how I can debug a C++ DLL from within Tradestation 10 by attaching VS2022 to the Tradestation process?
I can compile a DLL successfully and call a function from it for display within a Tradestation workspace. After a LOT of time spent browsing around on various MicroSoft learning pages etc etc, I have arrived at the following method but cannot get Visual Studio 2022 to load symbols or recognize the required .PDB file(s).
To complicate matters the DLL must be a release version and reside in the Tradestation system file for it to work with Tradestation. It is my understanding that this is ok so long as the relevent .pdb files are available to enable debugging. Here is my methodology so far:
1. Compile the C++ DLL in Visual Studio 2022 in RELEASE mode as specified for use in tradestation.
2. Set post build to copy MyDLL.dll and MyDLL.pdb to C:\Program Files (x86)\TradeStation 10.0\Program
3. Indicator using function from MyDLL.dll plots ok - great!
4. Set breakpoint in C++ code within function in Visual Studio 2022: breakpoint shows no errors.
5. Attempt to debug in release mode in VS 2022 by attaching Tradestation process using indicator/MyDLL to be debugged: Debug -> Attach to Process... -> ORPlat.exe
++++ Now things do not go to plan ++++++++
6. MyDLL.dll not listed in Modules window
7. Numerous messages appear in the Modules window such as:
ORPlat.exe C:\Program Files (x86)\TradeStation 10.0\Program\ORPlat.exe Cannot find or open the PDB file.
8. MyDLL.dll shows up as being loaded ok using DebugView
Compiler settings in VS2022 are:
/ifcOutput "Release\" /GS /GL /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /Od /Fd"Release\vc143.pdb" /Zc:inline /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "GLOBALVARIABLE23_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /FC /Fa"Release\" /EHsc /nologo /Fo"Release\" /Ot /Fp"Release\Future DLL.pch" /diagnostics:column
Am I flogging a dead horse here? Is it impossible to debug MyDLL.dll from within Visual Studio by attaching it to the Tradestation process (ORPlat.exe)? If it is not possible (such as debugging only from within Tradestation; how do you attempt serious debugging in complex C++ code within your MyDLL.dll functions?
Any help on this greatly appreciated!
Cheers
|
|
|
|
|
PaulS_UK wrote: 6. MyDLL.dll not listed in Modules window Sounds to me like your DLL is not being loaded by the process. Is there something you need to do to cause it to load the DLL, like maybe use a particular feature?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
PaulS_UK wrote: how do you attempt serious debugging in complex C++ code within your MyDLL.dll functions
Any language - I use logging.
Last time I did C++ I rolled my own. But googling I see Log4cxx and Log4cpp. I might go with the second but I would do more research first.
|
|
|
|
|
0
I need to read the TextBox input, my username and password work as below, but the file input and file output require another step to convert a string that can open the files.
I've tried every example I can find, cstring numerous times.I can't believe no one uses a textbox to open a file. Why can't i get an answer? Will someone please read this question and answer it. I see that some questions get numerous answers and I can't even get one answer. Please help me!
THESE 2 BELOW WORK private: System::Void usernameTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) { msclr::interop::marshal_context context; std::string myUsername = context.marshal_asstd::string(usernameTextString); }
private: System::Void passwordTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {
msclr::interop::marshal_context context;
std::string myPassword = context.marshal_as<std::string>(passwordTextString);
}
THESE 2 BELOW NEED AN ADDITIONAL LINE OF CODE TO OPEN THE FILES private: System::Void myInfileTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) { msclr::interop::marshal_context context; std::string myInfile = context.marshal_asstd::string(myInfileTextString); }
private: System::Void myOutfileTextBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {
msclr::interop::marshal_context context;
std::string myOutfile = context.marshal_as<std::string>(myOutfileTextString);
}
|
|
|
|
|
|
Hi,
in my MFC DLL, pMyDLLCWnd is pointer to a class driver from CWnd.
When CDialog is linked to DLL, timer starts.
When console is linked to DLL, same timer does not start.
pMyDLLCWnd->Settimer(ID,t,NULL)
DLL has wm_timer message handler.
|
|
|
|