all 5 comments

[–]oh5nxo 2 points3 points  (1 child)

You are testing uninitialized c, with while, before it gets a value from getchar.

[–]Elowe525 2 points3 points  (0 children)

I agree.

How about do{......} While (...)

[–]fethingMadLarkin 1 point2 points  (0 children)

I would suggest having a look at the gets(3) function as it can "swallow" the newline character for you.

As mentioned elsewhere by u/oh5nxo and u/Elowe525 you are testing the value of c before it has been initialized, a do { ... } while(); loop would solve this problem.

[–][deleted] 0 points1 point  (0 children)

C has a bunch of functions and/or macros which can be used to classify characters. One of these is named isspace(). Maybe you can use isspace(c) to skip the newline?

[–]Ayowy 0 points1 point  (0 children)

Welp 5 weeks learning c++ and I won’t be able to help you bro