我希望抑制函數smbc_opendir()的默認輸出,並僅使用printf進行打印。如何抑制庫函數的輸出
GCC FILENAME.C -lsmbclient
#include <libsmbclient.h>
#include <stdio.h>
void auth_fn()
{
}
int main(int argc,char* argv[])
{
int dirHandle;
if(smbc_init(auth_fn, 10)) /* Initialize things */
{
return 0;
}
dirHandle= smbc_opendir(argv[1]); /* Argument is smb://<ip-address>/ */
/* Just display value of dirHandle in output and nothing else */
printf("%d",dirHandle);
return 0;
}
如果'smbc_opendir'被寫入'stderr'那麼你可以暫時重定向'stderr'到'的/ dev/null',然後再把它恢復。 –
它寫入標準輸出 –
好 - 同樣的原則適用於'stdout'。 –