Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

How to use the scanf function in c++ and DAQmx fucntions

I just start using NIDAQmx with C functions.
I have a problem using scanf function and after the NIDAQmx functions.
Whithout the scanf function the program runs well but inserting this function is not running??
The program is like that:






DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else





int32 error=0,k=0;

TaskHandle taskHandle=0;

TaskHandle taskHandleCtr=0;

uInt64 sampsPerChanToAcquire=50;

int32 numSampsPerChan=50;

int j;

float64 rate=100;

uInt32 data[8]={1,0,1,0,1,0,1,0};

char errBuff[2048]={'\0'};


// DAQmx Configure Code


DAQmxErrChk (DAQmxCreateTask(


DAQmxErrChk (DAQmxCreateTask(






scanf (



DAQmxErrChk (DAQmxCreateDOChan(taskHandle,


DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,


DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleCtr,


DAQmxErrChk (DAQmxCfgImplicitTiming (taskHandleCtr,DAQmx_Val_FiniteSamps,500));


// DAQmx Write Code


DAQmxErrChk (DAQmxWriteDigitalU32(taskHandle,k,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));


// DAQmx Start Code


DAQmxErrChk (DAQmxStartTask(taskHandle));

DAQmxErrChk (DAQmxStartTask(taskHandleCtr));



0 Kudos
Message 1 of 3

Hi Novice 22

what is exactly the problem that you have when you run the program with scanf? does the function not work properly? What is the error code?

What is the environment where you are programming? And what is the type of C that you are using? ANSI C, C, C++, Visual C...

The code is right so I suppose that you forgot link the library or the path is wrong.

0 Kudos
Message 2 of 3

the problem is with the function scanf. When i used it, i can not write digital lines.

I have no signal on port when i use scanf

Environment: VC++ 2005, programming in ansi c.

Thank you,



0 Kudos
Message 3 of 3