Я пытаюсь прочитать разные строки ввода через файл, используя scanf.Мне удалось только прочитать первую строку и сохранить ее.
вот код, который я написал.
#include <stdio.h>
#include <string.h>
int imageWidth, imageHeight, safeRegionStart, safeRegionWidth;
main(void)
{
int i=0, j=0;
int totalP, pixel, totalSafeP, concat;
int unsigned r,g,b;
scanf("%d %d %d %d", &imageWidth, &imageHeight, &safeRegionStart, &safeRegionWidth);
totalP = imageWidth * imageHeight ;
totalSafeP = imageHeight * safeRegionWidth;
char arr[512][50];
char arr1[imageWidth][imageHeight];
printf("total # of pixels: %d\nTotal # of safe Pixels: %d\n", totalP, totalSafeP);
memset(arr,0x0,sizeof(arr));
while(i!=totalP)
{
i++;
scanf("%d", &pixel);
/*bit shifting to get r,g,b*/
int r = pixel << 8;
r = (unsigned int)logicalRightShift(r, 24);
int g = pixel << 16;
g = (unsigned int)logicalRightShift(g, 24);
int b = pixel << 24;
b = (unsigned int)logicalRightShift(b, 24);
//printf("%d) r:%d , g:%d , b:%d\n",i, r,g,b);
fillDescription(arr, r, g, b);
}/*End for scanning all pixels*/
}/*end main*/