Click here to Skip to main content
15,888,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: what's the use of this? Pin
Michael Dunn5-Mar-06 18:27
sitebuilderMichael Dunn5-Mar-06 18:27 
Questionto anyone who can explain further...thank you in advance Pin
not insane yet!5-Mar-06 17:25
not insane yet!5-Mar-06 17:25 
AnswerRe: to anyone who can explain further...thank you in advance Pin
Nibu babu thomas5-Mar-06 17:30
Nibu babu thomas5-Mar-06 17:30 
AnswerRe: to anyone who can explain further...thank you in advance Pin
Divyang Mithaiwala5-Mar-06 17:50
Divyang Mithaiwala5-Mar-06 17:50 
Questionproblem in a program code Pin
ashira khera5-Mar-06 17:16
ashira khera5-Mar-06 17:16 
QuestionRe: problem in a program code Pin
David Crow6-Mar-06 3:06
David Crow6-Mar-06 3:06 
Answerhow to replace first half with reversed 2nd half Pin
ashira khera6-Mar-06 8:19
ashira khera6-Mar-06 8:19 
QuestionRe: how to replace first half with reversed 2nd half Pin
David Crow6-Mar-06 8:37
David Crow6-Mar-06 8:37 
ashira khera wrote:
...only half of the file can be in memory and the other part in buffer...


Huh? Where else could the buffer reside if not in memory?

While it obviously wouldn't be the most efficient, how about using two variables: one to start at the beginning of the file, and the other to start at the end of the file? Read a character into each, swap them, write them back to disk, advance the two variables until they meet in the middle.

Another idea is something like:

void main( void )
{
    char szBuffer[] = "ABCDEFGHIJKLMNOPQRS"; // some buffer to reverse
    char *psTemp;
    int  x,
         y;
 
    // create temporary buffer to hold half
    psTemp = new char[strlen(szBuffer) / 2];
 
    // store first half in temporary buffer (memcpy would be quicker)
    for (x = 0; x < 10; x++)
        psTemp[x] = szBuffer[x];
 
    // overwrite second half with 'reversed' first half
    for (y = 0, x = strlen(szBuffer) - 1; x >= strlen(szBuffer) / 2; x--, y++)
    {
        char c      = szBuffer[x];
        szBuffer[x] = psTemp[y];
        psTemp[y]   = c;
    }
 
    // overwrite first half with 'reversed' second half (use memcpy)
    for (x = 0; x < strlen(szBuffer) / 2; x++)
        szBuffer[x] = psTemp[x];
}


"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

"There is no death, only a change of worlds." - Native American Proverb


QuestionProgram hangs when focused... Pin
the_augy5-Mar-06 15:27
the_augy5-Mar-06 15:27 
AnswerRe: Here's some more information Pin
the_augy5-Mar-06 21:46
the_augy5-Mar-06 21:46 
AnswerYour urgent query... Pin
BadJerry8-Jan-07 1:47
BadJerry8-Jan-07 1:47 
QuestionProgramming Tutor Pin
VegasMalone5-Mar-06 14:45
VegasMalone5-Mar-06 14:45 
AnswerRe: Programming Tutor Pin
John R. Shaw5-Mar-06 16:17
John R. Shaw5-Mar-06 16:17 
QuestionExtracting numbers from a year Pin
Titan905-Mar-06 13:05
Titan905-Mar-06 13:05 
AnswerRe: Extracting numbers from a year Pin
Michael Dunn5-Mar-06 13:22
sitebuilderMichael Dunn5-Mar-06 13:22 
AnswerRe: Extracting numbers from a year Pin
PJ Arends5-Mar-06 13:31
professionalPJ Arends5-Mar-06 13:31 
GeneralRe: Extracting numbers from a year Pin
Titan905-Mar-06 15:26
Titan905-Mar-06 15:26 
QuestionUsing .lib vs. .dll Pin
Eikthrynir5-Mar-06 12:12
Eikthrynir5-Mar-06 12:12 
AnswerRe: Using .lib vs. .dll Pin
Jörgen Sigvardsson5-Mar-06 12:44
Jörgen Sigvardsson5-Mar-06 12:44 
GeneralRe: Using .lib vs. .dll Pin
John R. Shaw5-Mar-06 16:08
John R. Shaw5-Mar-06 16:08 
AnswerRe: Using .lib vs. .dll Pin
Tim Smith5-Mar-06 14:05
Tim Smith5-Mar-06 14:05 
QuestionOpenGL MFC Pin
braveheartkenya5-Mar-06 11:14
braveheartkenya5-Mar-06 11:14 
AnswerRe: OpenGL MFC Pin
Steve Echols5-Mar-06 12:28
Steve Echols5-Mar-06 12:28 
Questionproblem calling NtQuerySystemInformation Pin
gamitech5-Mar-06 8:18
gamitech5-Mar-06 8:18 
QuestionCFileDialog Resource Pin
MON2055-Mar-06 6:26
MON2055-Mar-06 6:26 

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.