2013-05-20 70 views
-1

我用C語言編寫了一個簡單的代碼,使用NetCDF庫來讀取NetCDF文件。我編寫了查看Unidata提供的NetCDF C文檔的代碼。'&'令牌之前的語法錯誤

int ncid=0; 

    errstatus = nc_open("test2.pval.47000", NC_NOWRITE, &ncid); 
    if(errstatus) 
     handle_error(); 

    int ndims, ngatts, nvars, unlimdimid; 

    errstatus = nc_inq(ncid, &ndims. &nvars, &ngatts, &unlimdimid); 
    if(errstatus) 
     handle_error(); 

    printf("Number of dimesnions: %d\n", ndims); 
    printf("Number of variables: %d\n", nvars); 
    printf("Number of global attributes: %d\n", ngatts); 

我編譯的代碼通過命令

gcc -c -I/usr/local/include test.c 

,但我收到以下錯誤

test.c: In function `main': 
test.c:27: error: syntax error before '&' token 

能否請你幫我出。

+0

'&ndims.'應該是'&爲ndims,' – hmjd

+0

哪些線是線18和27? –

+0

對不起,我應該在發佈之前仔細查看代碼。 – user2401047

回答

1

只是在你的代碼中的錯字?如果不調用nc_inq

errstatus = nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid); 
          ^, not . 
+0

對不起,我應該在發佈之前仔細查看代碼。 – user2401047

相關問題