Use fopen() to open the file for input.
Use fscanf() to read each successive integer from the file. I would suggest using the %d format.

> ptr=(struct link *)malloc(sizeof(struct link));
If you had included stdlib.h (as you should have), then a cast of the result would not be necessary, at least for any ANSI/ISO C compiler.
If, after removing the cast, you get warnings about converting void*, then that means you need to stop compiling your code with a C++ compiler, and use a C compiler. Typically, this involves renaming "prog.cpp" into "prog.c".

Also, main should be explicitly declared as returning int, and have an explicit return 0; at the end.