ive been trying to learn c. in this program and a few others the app waits for EOF and i dunno how to send EOF on a terminal to make it work. i tried ^C and "." help plz?
#include <stdio.h>
/* count lines in input */
main()
{
int c, nl;
nl = 0;
while ((c = getchar()) != EOF)
if (c == '\n')
++nl;
printf("%d\n", nl);
}
Name:
Anonymous2013-09-30 12:59
If it ain't LISP, it's shit. Commit suicide.
Name:
Anonymous2013-09-30 13:15
fine then, how do you type in end of file into a running lisp program. it's surely the same.
>>2 If it ain't LISP, it's shit. Commit suicide.
But LISP is dead.
And C is faster.
Name:
Anonymous2013-09-30 14:00
^Z is suspend. it just pauses an app.
Name:
Namefag2013-09-30 14:06
C is pretty much anus. Use pythons.
Name:
Anonymous2013-09-30 14:57
(call-with-input-file "a.txt"
(lambda (input-port)
(let loop ((x (read-char input-port)))
(if (not (eof-object? x))
(begin
(display x)
(loop (read-char input-port))))))) Taken from StackOverflow, a place full of helpful people and answers. If you're struggling with something, StackOverflow is probably your best bet. And now that the StackExchange network has expanded so greatly, there are Q&A resources for almost every topic imaginable!
Name:
Anonymous2013-09-30 15:21
thanks, i found it on stackoverflow. eof is ^z for ms-dos and ^D for windows. the app worked perfectly after that.