C program that displays shapes. Keep getting errors.
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.
You're attacking this all wrong. First you need to indent like Nylex said.
Quote:
Originally Posted by Nylex
Again, it would help if you put indentation in.
Another issue that I have with you doing is your fancy for loops not using curly brackets {}. Although it is not programmatically incorrect it is a bad habit just like not indenting. The reason is you end up with code like this (directly pulled from your code):
So in the future you should write your for loops like so which will make your code more accurate and easier to read if you're on a project with more than one person programming:
Code:
for(k=1; k<=i; k=k+1)
{
printf("*");
}
That problem occurs at line 41 of your code which I will give you back fully indented. Make indenting a habit and your troubleshooting will get dramatically easier and you'll find that you can easily write accurate code the first time.
That is not inside of your main function at all... indenting would have avoided that.
As for the rest of your code I think another member would better be able to help you using the indented version. I don't know how to program C. At least not outside your basic hello world or embedded circuits.
Since you're on Windows hopefully you're not using Notepad. Better to use something like Notepad++ which is what I formatted your code in around 15 seconds.
...
Sergei, i was hoping for help directly, not getting refered to a book.
And that's the problem. Various posters including myself pointed you to the exact places in your code which are hopelessly wrong. And you were given sources of info to get knowledge from.
Instead of reading and then asking you insist on being lazy and exploiting others. I.e. you are fiercely resiting reading and comprehending. In real life standards are sometimes 700 pages long and maybe longer. Nobody will hold your hand begging you to read.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.