#include <stdlib.h>
int main()
{
int chars, i = 0;
char a, b;
char *ptr;
while (i < 3)
{
printf("Employee %d: Enter the number of characters in your Employee Id\n", i+1);
scanf("%d", &chars);
getchar();
printf("Enter the value of a\n");
scanf("%c", &a);
getchar();
printf("Enter the value of b\n");
scanf("%c", &b);
ptr = (char *) malloc((chars+1)*sizeof(char));
printf("Enter your Employee Id\n");
scanf("%s", ptr);
printf("Your Employee Id is %s\n",ptr );
free(ptr);
i = i + 1;
}
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter