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

C / C++ / MFC

 
AnswerRe: strcpy dilemma - it works half way Pin
CPallini3-Aug-15 21:08
mveCPallini3-Aug-15 21:08 
GeneralRe: strcpy dilemma - it works half way Pin
Vaclav_4-Aug-15 3:49
Vaclav_4-Aug-15 3:49 
GeneralRe: strcpy dilemma - it works half way Pin
CPallini4-Aug-15 6:54
mveCPallini4-Aug-15 6:54 
GeneralSOLVED Re: strcpy dilemma - it works half way Pin
Vaclav_4-Aug-15 7:41
Vaclav_4-Aug-15 7:41 
AnswerRe: strcpy dilemma - it works half way Pin
Arthur V. Ratz13-Aug-15 18:54
professionalArthur V. Ratz13-Aug-15 18:54 
QuestionMsbuild for VC++ project having path errors Pin
code_az3-Aug-15 12:54
code_az3-Aug-15 12:54 
Questionruntime error due to corruption of heap Pin
Member 93502372-Aug-15 22:22
Member 93502372-Aug-15 22:22 
AnswerRe: runtime error due to corruption of heap Pin
Member 93502372-Aug-15 22:33
Member 93502372-Aug-15 22:33 
This is my main program..I'm sorry to post whole bunch of code here!, but I'm wondering this may helps someone can pointout the issue
C++
int main(int argc, char* argv[])
{

<pre>
char fname[30];
char fpath[100]; // file name for logging
char fpath1[100]; // file name for logging
char fpath2[100];

// implimentation for genrating force enable bool array
memset(boolArray,0,sizeof(bool)*arraySize);

bool *pBool =boolArray + 10;
srand( (unsigned)time(NULL));
int rIndex2;

for(int i=0;i<10;++i){

    memset(pBool,1,sizeof(bool)*12);
    //memset(pBool,1,sizeof(bool));
    int rIndex = rand()%12;

    pBool[rIndex]=0;
        do{
            //int rIndex2;

            rIndex2 = rand()%12;
            pBool[rIndex2]=0;
          } while (rIndex2==rIndex);
    //pBool = rand()%2;
    pBool +=12;
}

for (int j=0; j<NTRIALS;j++) //check!!
printf("%d\t", boolArray[j]);

printf ("\n");
printf ("-----------------------------------\n");

printf ("-----------------------------------\n");
printf ("\n\n");

printf ("File name for logging:");
scanf("%s",fname);
printf ("\n\n");

printf ("[x] - Exit application\n");
printf ("\n\n");

// parse first arg to try and locate resources
resourceRoot = string(argv[0]).substr(0,string(argv[0]).find_last_of("/\\")+1);

    sprintf(fpath,"%s\\%s%0d.dat",rootdir,fname);

    pFile = fopen (fpath, "wb");

   // sprintf(fpath1,"%s\\%s%0d.pro",rootdir,fname,epoch);
    sprintf(fpath1,"%s\\%s%0d.pro",rootdir,fname);
    pFile1 = fopen (fpath1, "w");

   // sprintf(fpath2,"%s\\%s%0d.arr",rootdir,fname,epoch);
     sprintf(fpath2,"%s\\%s%0d.arr",rootdir,fname);
    pFile2 = fopen(fpath2,"w");

    for (int j=0; j<NTRIALS;j++)  fprintf(pFile2, "%d\t",boolArray[j]);

//-----------------------------------------------------------------------
// HAPTIC DEVICES / TOOLS
//-----------------------------------------------------------------------

// create a haptic device handler
handler = new cHapticDeviceHandler();

// read the number of haptic devices currently connected to the computer
numHapticDevices = handler->getNumDevices();

// limit the number of devices to MAX_DEVICES
numHapticDevices = cMin(numHapticDevices, MAX_DEVICES);

//-----------------------------------------------------------------------
// 3D - SCENEGRAPH
//-----------------------------------------------------------------------

//Seperated into two if statements
int screenW = glutGet(GLUT_SCREEN_WIDTH);
int screenH = glutGet(GLUT_SCREEN_HEIGHT);
int windowPosX1 = 0; 
int windowPosY1 = 0; 
int windowPosX2 = WINDOW_SIZE_W;
int windowPosY2 = 0;

/*glutCreateMenu(menuSelect);
glutAddMenuEntry("full screen", OPTION_FULLSCREEN);
glutAddMenuEntry("window display", OPTION_WINDOWDISPLAY);
glutAttachMenu(GLUT_RIGHT_BUTTON);*/

glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowSize (WINDOW_SIZE_W/2, WINDOW_SIZE_H/2);

//glutInitWindowPosition (windowPosX, windowPosY);

mytimer.start(true);  // start clock after reset to zero...
statetimer.start(true);

int i = 0;
    while (i < numHapticDevices){    

    // get a handle to the next haptic device
    cGenericHapticDevice* newHapticDevice;

    handler->getDevice(newHapticDevice, i);
    printf("index number of device-> %d \n\n", i);

    // open connection to haptic device
    newHapticDevice->open();

    // initialize haptic device
    newHapticDevice->initialize();

    // store the handle in the haptic device table
    hapticDevices[i] = newHapticDevice;

    // retrieve information about the current haptic device
    cHapticDeviceInfo info = newHapticDevice->getSpecifications();

    CreateWorld(world[i],camera[i],cursors[i],starts[i],targets[i],via[i],labels[i],scorelabels[i]
    ,forcevectors[i],poslabels[i], waitlabels[i]);   
    char str[30];
    sprintf(str,"ROBOT %d",i);
    window[i] = glutCreateWindow (str);
    //

    ///
    if (i==0) {
        glutInitWindowPosition (windowPosX1, windowPosY1);
        glutDisplayFunc(updateGraphics1);
    }
    else { 
        glutInitWindowPosition (windowPosX2, windowPosY2);
        glutDisplayFunc(updateGraphics2);
    }

    glutReshapeFunc(reshape);

    glutKeyboardFunc(keySelect);

    // window modification

    //glutKeyboardFunc(keySelect1);
    i++;
}

// Different VIA Points!!!
via[0]->setPos(cVector3d( 0, 0.02, 0.03));
//via[1]->setPos(cVector3d( 0, -0.02, 0.03));
via[1]->setPos(cVector3d( 0, -0.02, -0.03));

//-----------------------------------------------------------------------
// START SIMULATION
//-----------------------------------------------------------------------

// simulation in now running
simulationRunning = true;

// create a thread which starts the main haptics rendering loop
cThread* hapticsThread = new cThread();
hapticsThread->set(updateHaptics, CHAI_THREAD_PRIORITY_HAPTICS);

// This is to periodically log data (time, position, force, state) on a buffer
cThread* loggingThread = new cThread();
loggingThread->set(updateLogging, CHAI_THREAD_PRIORITY_HAPTICS);

// This is to flush data on a file
cThread* IOThread = new cThread();
IOThread->set(IOflush, CHAI_THREAD_PRIORITY_GRAPHICS);

// start the main graphics rendering loop
glutMainLoop();
mytimer.stop();
statetimer.stop();
// close the data file
fclose(pFile);
fclose(pFile1);
fclose(pFile2);

//}
    close();
// exit
return (0);

}
SuggestionRe: runtime error due to corruption of heap Pin
David Crow3-Aug-15 2:12
David Crow3-Aug-15 2:12 
AnswerRe: runtime error due to corruption of heap Pin
Daniel Pfeffer3-Aug-15 0:52
professionalDaniel Pfeffer3-Aug-15 0:52 
AnswerRe: runtime error due to corruption of heap Pin
Jochen Arndt3-Aug-15 2:13
professionalJochen Arndt3-Aug-15 2:13 
QuestionConvert to ASCII ? Pin
Vaclav_1-Aug-15 3:52
Vaclav_1-Aug-15 3:52 
AnswerRe: Convert to ASCII ? Pin
CPallini1-Aug-15 4:15
mveCPallini1-Aug-15 4:15 
AnswerRe: Convert to ASCII ? Pin
Richard MacCutchan1-Aug-15 4:33
mveRichard MacCutchan1-Aug-15 4:33 
GeneralRe: Convert to ASCII ? Pin
Vaclav_1-Aug-15 9:40
Vaclav_1-Aug-15 9:40 
GeneralRe: Convert to ASCII ? Pin
Richard MacCutchan1-Aug-15 21:00
mveRichard MacCutchan1-Aug-15 21:00 
GeneralRe: Convert to ASCII ? Pin
CPallini2-Aug-15 6:56
mveCPallini2-Aug-15 6:56 
QuestionEfficient way of converting an 8bit array of grayscale pixel data into 24bpp bitmap for GDI+? Pin
Kiran Satish31-Jul-15 8:39
Kiran Satish31-Jul-15 8:39 
QuestionRe: Efficient way of converting an 8bit array of grayscale pixel data into 24bpp bitmap for GDI+? Pin
CPallini31-Jul-15 21:40
mveCPallini31-Jul-15 21:40 
AnswerRe: Efficient way of converting an 8bit array of grayscale pixel data into 24bpp bitmap for GDI+? Pin
Jochen Arndt31-Jul-15 21:51
professionalJochen Arndt31-Jul-15 21:51 
GeneralPassing an "array" in C Pin
PIEBALDconsult31-Jul-15 7:41
mvePIEBALDconsult31-Jul-15 7:41 
GeneralRe: Passing an "array" in C Pin
k505431-Jul-15 7:55
mvek505431-Jul-15 7:55 
GeneralRe: Passing an "array" in C Pin
PIEBALDconsult31-Jul-15 8:34
mvePIEBALDconsult31-Jul-15 8:34 
SuggestionRe: Passing an "array" in C Pin
camycentsolutions2-Aug-15 19:36
camycentsolutions2-Aug-15 19:36 
GeneralRe: Passing an "array" in C Pin
Chris Losinger31-Jul-15 9:50
professionalChris Losinger31-Jul-15 9:50 

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.