Click here to Skip to main content
14,327,160 members

C / C++ / MFC

 
AnswerRe: Strange Compiler behavior Pin
ForNow2-May-15 15:12
memberForNow2-May-15 15:12 
GeneralRe: Strange Compiler behavior Pin
Richard MacCutchan2-May-15 20:50
protectorRichard MacCutchan2-May-15 20:50 
GeneralRe: Strange Compiler behavior Pin
ForNow2-May-15 21:05
memberForNow2-May-15 21:05 
QuestionCWinThread::CAsyncSocket::Create issues Pin
ForNow28-Apr-15 4:52
memberForNow28-Apr-15 4:52 
AnswerCode works in CWInThread constructer ? Pin
ForNow29-Apr-15 6:03
memberForNow29-Apr-15 6:03 
GeneralRe: Code works in CWInThread constructer ? Pin
Albert Holguin1-May-15 4:40
professionalAlbert Holguin1-May-15 4:40 
GeneralRe: Code works in CWInThread constructer ? Pin
ForNow1-May-15 6:16
memberForNow1-May-15 6:16 
Questionswscanf_s White Space Help Pin
Jesuaw28-Apr-15 4:09
memberJesuaw28-Apr-15 4:09 
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?
AnswerRe: swscanf_s White Space Help Pin
k505428-Apr-15 5:41
memberk505428-Apr-15 5:41 
GeneralRe: swscanf_s White Space Help Pin
Jesuaw28-Apr-15 6:50
memberJesuaw28-Apr-15 6:50 
GeneralRe: swscanf_s White Space Help Pin
k505428-Apr-15 7:05
memberk505428-Apr-15 7:05 
GeneralRe: swscanf_s White Space Help Pin
Jesuaw28-Apr-15 7:49
memberJesuaw28-Apr-15 7:49 
QuestionMapViewOfFIle in Client and Server returning 2 different address Pin
ForNow24-Apr-15 11:40
memberForNow24-Apr-15 11:40 
AnswerRe: MapViewOfFIle in Client and Server returning 2 different address Pin
Richard Andrew x6424-Apr-15 12:06
professionalRichard Andrew x6424-Apr-15 12:06 
GeneralRe: MapViewOfFIle in Client and Server returning 2 different address Pin
ForNow24-Apr-15 12:31
memberForNow24-Apr-15 12:31 
AnswerRe: MapViewOfFIle in Client and Server returning 2 different address Pin
Frankie-C25-Apr-15 7:37
memberFrankie-C25-Apr-15 7:37 
GeneralRe: MapViewOfFIle in Client and Server returning 2 different address Pin
ForNow25-Apr-15 15:09
memberForNow25-Apr-15 15:09 
QuestionInterProcess communication questions Pin
ForNow24-Apr-15 8:44
memberForNow24-Apr-15 8:44 
AnswerRe: InterProcess communication questions Pin
Frankie-C25-Apr-15 7:35
memberFrankie-C25-Apr-15 7:35 
GeneralRe: InterProcess communication questions Pin
ForNow25-Apr-15 15:08
memberForNow25-Apr-15 15:08 
QuestionSynchronizing access to data Pin
ramonlarodo22-Apr-15 21:55
memberramonlarodo22-Apr-15 21:55 
QuestionRe: Synchronizing access to data Pin
Richard MacCutchan22-Apr-15 23:25
protectorRichard MacCutchan22-Apr-15 23:25 
QuestionCDateTimeCtrl editing short year format Pin
baerten22-Apr-15 21:51
memberbaerten22-Apr-15 21:51 
QuestionRe: CDateTimeCtrl editing short year format Pin
Richard MacCutchan22-Apr-15 23:23
protectorRichard MacCutchan22-Apr-15 23:23 
AnswerRe: CDateTimeCtrl editing short year format Pin
baerten24-Apr-15 0:06
memberbaerten24-Apr-15 0:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.