I'm starting C as my first language and am just under halfway done the book I'm using. However, I commonly hear about 'bad' programmers and 'bad' code whenever I encounter any sort of programming related discussion on the internet.
I've done some examples that do work as they should but, I want to make sure that when I eventually am able to contribute to projects on GitHub, etc. that I'm not screwing everything up and writing unmaintainable code.
Do these examples follow common best practices? I did have comments but took them out as the code should be easy enough to understand and it's the actual code I'm wondering about.
/*make a box*/
#include <stdio.h>
int main(void)
{
int i = 0;
int long length = 0;
int long width = 0;
printf("Enter Box dimensions (LxW):");
scanf("%ld %ld", &length, &width);
for(i = 0; i <= width; i++)
{
printf("*");
}
for(i = 0; i <= length; i++)
{
printf("\n*");
for(int a = 0; a <= (width-2); a++)
{
printf(" ");
}
printf("*");
}
printf("\n");
for(i = 0; i <= width; i++)
{
printf("*");
}
return 0;
}