hey there,
i want to write a c program to read array from a text file .....which looks something like this
ex.txt
123
245
465
12
37
84
984

i want to write a program to read these values and subtract each value from the next one(like 245-123,465-245,....and so on till end of file) and store result into another txt file.
i would be glad if somebody could suggest me how to do this.
Thank you very much.

lets say you have two integers, n1 and n2

open file for input
read first integer into n1
start of loop to read until end-of-file
   read integer into n2
   subtract n2 - n1 and save result in a second file
   move value of n2 into n1
end of loop

Can you show me an example.
that would be very helpful.

Why don't you give it a go, see how far you get, then post what you can achieve yourself.

Then we'll tell you where you're going wrong, and suggest how you should proceed towards your goal.

It'll teach you a lot more than simply looking at someone else's code.

You can't become a great cook simply by being a food taster.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.