|
Hello,
A wchar_t array contains two sentences inside which I need to save in two separate variables.
wchar_t str[] = L"'This is the first sentence' 'This is the second sentence'";
I want to split in a way that first sentence and second sentence equals to these:
wchar_t first_sentence[MAX_PATH]=L"'This is the first sentence'";
wchar_t second_sentence[MAX_PATH]=L"'This is the second sentence'";
I am using below code but it does not work as expected.
#include "stdafx.h"
#include <wchar.h>
#include <windows.h>
#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
wchar_t str[] = L"'This is the first sentence' 'This is the second sentence'";
wchar_t first_sentence[MAX_PATH];
wchar_t second_sentence[MAX_PATH];
swscanf_s(str, L"'%s' '%s'", first_sentence, _countof(first_sentence), second_sentence, _countof(second_sentence));
printf("first_sentence=%ls\nsecond_sentence=%ls\n", first_sentence, second_sentence);
system("PAUSE");
return 0;
}
As far as I understand swscanf_s is pausing when it encountes the first white space. How am I suppose to get whole string between single quotes with swscanf_s please?
|
|
|
|
|
the format specifier you want is %[^'] i.e. all chars that are not a single quote.
|
|
|
|
|
Thank you very much for your help. Works great.
One more question please. How can I select all the characters till to a specific word?
Say, I want to select all characters till "the" word? I tried
%[^(the)]
but to no avail.
Cheers
|
|
|
|
|
Even if that worked, it probably wouldn't do what you wanted - e.g. if the input text was "a small withered man with the axe", you'd get "a small wi" copied to your output variable.
Depending on what you're trying to do, maybe regex() might be a better tool in this case, though I'm not sure about regex() and wide strings.
|
|
|
|
|
I see. Thanks again for your help.
Cheers
|
|
|
|
|
Hi,
In server program I do a createfilemapping followed by MapViewOfFile
in The Client I do a OpenFileMapping using the name last parameter from CreateFilemapping
and then I do a MapViewOfFile and I get 2 different address from MapViewOfFile in the
Client and Server
shouldn't they be the same since its shared storage
Thanks
|
|
|
|
|
No. They will be different because the processes are different.
The addresses will be different but the data is guaranteed to be the same between the two.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Technically:
the physical memory is the same, but the MMU maps it to available free logical address in the destination process.
|
|
|
|
|
|
Hi
If Do a CreateProcess with bInheritHandles set to true
and I create a event with name/string in the Parent Process
In the Child I do a OpenEvent
Do I still have to do a DuplicateHandle to have access to the event handle
|
|
|
|
|
No you don't need to duplicate handle if you have enabled inheritance int the CreateEvent of parent process setting lpEventAttributes parameter.
You need a duplicated handle if the event is created in the child process.
For detailed info see[^].
|
|
|
|
|
|
What I am trying to do is each thread gets to print out its 5 characters before potentially yielding to another thread. It works but it does not do what I want. THanks for help.
for (unsigned i = 0; i < _repCount; ++i) {
unique_lock<mutex> lck(mtx);
cv.wait(lck, []{return !inUse; });
inUse = true;
for (auto c : _printMe) {
cout << c;
cout.flush();
}
inUse = false ;
}
|
|
|
|
|
ramonlarodo wrote: It works but it does not do what I want. What do you want?
|
|
|
|
|
Hi everybody,
is there a possibility to edit the year in the short format(yy) aswell?
I set the format "dd.MM.yy" and the date is shown correctly as "23.04.15"
But if I place the cursor in the year-section, the year switches from 15 to 2015.
I need that the year keeps 15 at the edit-mode.
Big thanks for any information
Regards
-baerten-
|
|
|
|
|
What edit mode are you talking about? Where is this value displayed that changes, and how is the change displayed?
|
|
|
|
|
Thanks for your reply
I call it edit mode if I place simply the cursor into it.
Without the focus the control displays 24.04.15
If I place the cursor in the day section of the control it displays 24.04.15
If I place the cursor in the year section of the control it displays 24.04.2015
I use Visual Studio 2013. It has the same behaviour on Windows 7 and 8
Thanks for any information
|
|
|
|
|
So exactly what programming problem are you having?
|
|
|
|
|
I use the short format of the DateTime Control.
So, I want only 2 digits for the year.
But if I place the cursor in the year, it becomes 4 digits.
Is there a possibility to avoid this?
To recreate the OnDraw/OnKey logics is not so rational 
|
|
|
|
|
Hi Guys,
I have a weird problem debugging my project.
I have upgraded my VS 2008 project to VS 2010 by opening the solution file and successfully built the project (debug and release configurations). But when I run the project within Visual Studio I get the following weird error saying:
"Unable to start program"
"System cannot find the file specified"
Anyone knows hows how to fix this issue.
thanks
|
|
|
|
|
Something is either wrong with the project, or it has not built properly. Try a clean and rebuild, and check the output directories to make sure it has been properly created.
|
|
|
|
|
It build successfully. But if I try running the debug application within Visual studio (by key F5) I can't proceed.
|
|
|
|
|
Member 9350237 wrote: I can't proceed. Without more information we have no way of guessing what may be wrong. Look in the directory tree for the project and check that the excutable actually exists. Try starting it from Windows Explorer to see if it runs.
|
|
|
|
|
If you have multiple project in your solution, check that your project is really the "Startup Project"
I'd rather be phishing!
|
|
|
|