-1
我有興趣從文件中讀取CvPoint *類型的點,但我嘗試過標準符號(x,y)。當我嘗試驗證輸出時,它會給出錯誤的值。在文件中讀取CvPoint的格式是什麼?從文件中讀取CVPoint
point.txt
(1,1)
的main.cpp
points = (CvPoint*)malloc(length*sizeof(CvPoint*));
points1 = (CvPoint*)malloc(length*sizeof(CvPoint*));
points2 = (CvPoint*)malloc(length*sizeof(CvPoint*));
fp = fopen(points.txt, "r");
fscanf(fp, "%d", &(length));
printf("%d \n", length);
i = 1;
while(i <= length)
{
fscanf(fp, "%d", &(points[i].x));
fscanf(fp, "%d", &(points[i].y));
printf("%d %d \n",points[i].x, points[i].y);
i++;
}
它打印:
1
12 0