#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int size = 0;
do
{
printf("Put in size of the list (Range[1;2^16-1]): ");
scanf("%d", &size);//input
if (size <= 0)
printf("Put in a correct length!\n");
} while (size <= 0);
char temp[size+1];
while (fgets(temp, size, stdin))//break with ^Z or ^D
{
}
for (int i = 0; i < size; i++)//output
{
printf("%c", temp[i]);
printf("%d", i);
}
return 0;
}
Output:
Put in size of the list (Range[1;2^16-1]): 5
pizza
^Z(my powershell input)
a012z34
I tried to use the fgets()
function but it doesnt recognize all chars, only the last two chars. So I did some research but I couldn't find anything.