Click here to Skip to main content
15,887,241 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Strange Compiler behavior Pin
ForNow2-May-15 15:12
ForNow2-May-15 15:12 
GeneralRe: Strange Compiler behavior Pin
Richard MacCutchan2-May-15 20:50
mveRichard MacCutchan2-May-15 20:50 
GeneralRe: Strange Compiler behavior Pin
ForNow2-May-15 21:05
ForNow2-May-15 21:05 
QuestionCWinThread::CAsyncSocket::Create issues Pin
ForNow28-Apr-15 4:52
ForNow28-Apr-15 4:52 
AnswerCode works in CWInThread constructer ? Pin
ForNow29-Apr-15 6:03
ForNow29-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
ForNow1-May-15 6:16 
Questionswscanf_s White Space Help Pin
Jesuaw28-Apr-15 4:09
Jesuaw28-Apr-15 4:09 
Hello,

A wchar_t array contains two sentences inside which I need to save in two separate variables.

C++
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:

C#
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.

XML
#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
mvek505428-Apr-15 5:41 
GeneralRe: swscanf_s White Space Help Pin
Jesuaw28-Apr-15 6:50
Jesuaw28-Apr-15 6:50 
GeneralRe: swscanf_s White Space Help Pin
k505428-Apr-15 7:05
mvek505428-Apr-15 7:05 
GeneralRe: swscanf_s White Space Help Pin
Jesuaw28-Apr-15 7:49
Jesuaw28-Apr-15 7:49 
QuestionMapViewOfFIle in Client and Server returning 2 different address Pin
ForNow24-Apr-15 11:40
ForNow24-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
ForNow24-Apr-15 12:31 
AnswerRe: MapViewOfFIle in Client and Server returning 2 different address Pin
Frankie-C25-Apr-15 7:37
Frankie-C25-Apr-15 7:37 
GeneralRe: MapViewOfFIle in Client and Server returning 2 different address Pin
ForNow25-Apr-15 15:09
ForNow25-Apr-15 15:09 
QuestionInterProcess communication questions Pin
ForNow24-Apr-15 8:44
ForNow24-Apr-15 8:44 
AnswerRe: InterProcess communication questions Pin
Frankie-C25-Apr-15 7:35
Frankie-C25-Apr-15 7:35 
GeneralRe: InterProcess communication questions Pin
ForNow25-Apr-15 15:08
ForNow25-Apr-15 15:08 
QuestionSynchronizing access to data Pin
ramonlarodo22-Apr-15 21:55
ramonlarodo22-Apr-15 21:55 
QuestionRe: Synchronizing access to data Pin
Richard MacCutchan22-Apr-15 23:25
mveRichard MacCutchan22-Apr-15 23:25 
QuestionCDateTimeCtrl editing short year format Pin
baerten22-Apr-15 21:51
baerten22-Apr-15 21:51 
QuestionRe: CDateTimeCtrl editing short year format Pin
Richard MacCutchan22-Apr-15 23:23
mveRichard MacCutchan22-Apr-15 23:23 
AnswerRe: CDateTimeCtrl editing short year format Pin
baerten24-Apr-15 0:06
baerten24-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.