printing th number of line

hey guys,
this is urgent! i have an assignment where have to read contenets of a file character by character and whenever get an unexpected character the program is supposed to tell the user at what line the program stopped and exit the program. i just need to know how do i show the user the number of the line. i really don't know what to write in order t make this work and i am new in th world of programing. i am facing a lot of problems .can someone give me an example on this so that can apply it to the assignment. thank you all :)
Last edited on
take character.
If character is newline, then increase line number variable.
If run into unexpected char, print line number

OR

getline().
increase line variable.
Parse string.
Print line number if run into unexpected character.
thank you a lot :) this was really helpful:) you saved me :)
Topic archived. No new replies allowed.