Click here to Skip to main content
14,300,956 members

C / C++ / MFC

 
GeneralRe: Basic Server/Client TCP/IP Software Examples Pin
jschell26-Jan-19 5:52
memberjschell26-Jan-19 5:52 
AnswerRe: Basic Server/Client TCP/IP Software Examples Pin
Richard MacCutchan6-Jan-19 22:35
protectorRichard MacCutchan6-Jan-19 22:35 
QuestionRe initializing an array in C++ ? Pin
Vaclav_26-Dec-18 7:39
memberVaclav_26-Dec-18 7:39 
QuestionRe: Re initializing an array in C++ ? Pin
David Crow26-Dec-18 7:51
memberDavid Crow26-Dec-18 7:51 
AnswerRe: Re initializing an array in C++ ? Pin
Vaclav_26-Dec-18 8:20
memberVaclav_26-Dec-18 8:20 
QuestionRe: Re initializing an array in C++ ? Pin
David Crow26-Dec-18 14:08
memberDavid Crow26-Dec-18 14:08 
AnswerRe: Re initializing an array in C++ ? Pin
Richard MacCutchan26-Dec-18 22:29
protectorRichard MacCutchan26-Dec-18 22:29 
AnswerRe: Re initializing an array in C++ ? Pin
Vaclav_27-Dec-18 6:02
memberVaclav_27-Dec-18 6:02 
Here is a partial test solution using memset.
Compiler likes it.

There is a small problem

"This function copies the value of c (converted to an unsigned char) into each of the first size bytes
of the object beginning at block. It returns the value of block. "

I am getting only the first value passed and it fills all 32 bits

Index 0 pDataArray 37373737
Index 1 pDataArray 37373737
Index 2 pDataArray 37373737
Index 3 pDataArray 37373737

Obviously I am using the pDataArray
and memset (pointers ?) wrong, as usual.
Could use some more help.

Thanks
Cheers
Vaclav



    int *pDataArray;
int a[] = { 55, 1, 2, 3 };
int iTestIndex = 0;

memset(pDataArray, *a, sizeof(a));

do {
    cout << "index " << dec << iTestIndex; //  << endl;
    cout << " array 0x" << hex << +a[iTestIndex] << endl;
} while (iTestIndex++ != sizeof(a)/4); // temp /4

iTestIndex = 0;
do {
    cout << "index " << dec << iTestIndex;//  << endl;
    cout << " pDataArray " << hex << +pDataArray[iTestIndex] << endl;
    //} while (pDataArray[iTestIndex++]);
} while (iTestIndex++ != sizeof(a)/4);

    exit(1);   // test stop

int b[32] = { 4, 5, 6 };
memset(pDataArray, b[32], sizeof(b));
iTestIndex = 0;
do {
    cout << "index " << dec << iTestIndex << endl;
    cout << " pDataArray " << hex << +pDataArray[iTestIndex] << endl;
    //} while (pDataArray[iTestIndex++]);
} while (iTestIndex++ < 16);

GeneralRe: Re initializing an array in C++ ? Pin
Richard MacCutchan27-Dec-18 6:54
protectorRichard MacCutchan27-Dec-18 6:54 
GeneralRe: Re initializing an array in C++ ? Pin
Victor Nijegorodov27-Dec-18 7:16
memberVictor Nijegorodov27-Dec-18 7:16 
AnswerRe: Re initializing an array in C++ ? Pin
Vaclav_27-Dec-18 9:09
memberVaclav_27-Dec-18 9:09 
GeneralRe: Re initializing an array in C++ ? Pin
Richard MacCutchan27-Dec-18 22:16
protectorRichard MacCutchan27-Dec-18 22:16 
QuestionC programming Question on Characters Pin
Member 1409794322-Dec-18 7:12
memberMember 1409794322-Dec-18 7:12 
AnswerRe: C programming Question on Characters Pin
David Crow22-Dec-18 16:46
memberDavid Crow22-Dec-18 16:46 
GeneralRe: C programming Question on Characters Pin
Member 1409794322-Dec-18 20:32
memberMember 1409794322-Dec-18 20:32 
GeneralRe: C programming Question on Characters Pin
jschell23-Dec-18 7:44
memberjschell23-Dec-18 7:44 
GeneralRe: C programming Question on Characters Pin
David Crow23-Dec-18 12:50
memberDavid Crow23-Dec-18 12:50 
GeneralRe: C programming Question on Characters Pin
David Crow23-Dec-18 12:54
memberDavid Crow23-Dec-18 12:54 
AnswerRe: C programming Question on Characters Pin
jschell23-Dec-18 7:43
memberjschell23-Dec-18 7:43 
AnswerRe: Spurious end of file error from ifstream::read Pin
Richard MacCutchan22-Dec-18 4:37
protectorRichard MacCutchan22-Dec-18 4:37 
QuestionPostMessage fails with ERROR_NOT_ENOUGH_QUOTA (PROBLEM FOUND, thanks all) Pin
Maximilien19-Dec-18 4:53
memberMaximilien19-Dec-18 4:53 
QuestionRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
David Crow19-Dec-18 5:13
memberDavid Crow19-Dec-18 5:13 
AnswerRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Maximilien19-Dec-18 6:45
memberMaximilien19-Dec-18 6:45 
AnswerRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Richard MacCutchan19-Dec-18 5:15
protectorRichard MacCutchan19-Dec-18 5:15 
GeneralRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Maximilien19-Dec-18 6:46
memberMaximilien19-Dec-18 6:46 

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.