Linux.com

trouble with c

Link to this post 28 Apr 12

hey, i'm trying to learn c so i wrote a program that doesn't do exactly what i want it to, try as i might i couldn't find the bug so i was hoping you could help me out.

here's the program: http://pastebin.com/1uYraxeM

and here's the input, output, and expected output: http://pastebin.com/7bmEuvP8

any help you could give me i would be very greatful for

Link to this post 28 Apr 12

I not so good at C but I think this is the problem:
You type more than what getchar takes and put in s. the rest needs to be flushed.
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044873249&id=1043284392

edit: Newer mind this I did read it wrong
[I not so good at C but obvious line 29 don't do what we want it to do.
I think the best thing to do is to use the lim value so you newer add to much chars to the s array in the first place.
Your not getting any out of bounds error messages?]

Link to this post 30 Sep 12

Please, Tell us what terminal, charset and operating system you are using. Assumed you run it on a different platform than GNU/Linux you should pay attention on different line delimiter(s).

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board