ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It does loop, but you must enter a character to continue. The value being stored in c is of type int and not a character. So your out put will be different.
Originally posted by cxel91a It does loop, but you must enter a character to continue. The value being stored in c is of type int and not a character. So your out put will be different.
It does loop, but when I output the value of 't', it seems has it looped once before already...
Code:
[Mirrus][stratus][04:28:53][/Source][$] /Exec/new1
a
The value of 't' is 0
The value of 't' is 1
a
The value of 't' is 2
The value of 't' is 3
a
The value of 't' is 4
The value of 't' is 5
a
The value of 't' is 6
The value of 't' is 7
a
The value of 't' is 8
The value of 't' is 9
a
The value of 't' is 10
0
[Mirrus][stratus][04:29:01][/Source][$]
It guess it just reads once, loops, skips the call to 'getchar()' , loops again and reads again. I understand...sure I do.
Originally posted by jim mcnamara Avoid scanf() - for a lot of reasons. Use fgets() instead.
I do, and if I ever make a program of relevence I wouldnt use it, I would still like to fix its problems though, or write a similar(in some ways) function that doesnt store a newline.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.