Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

My new c code

Name: Anonymous 2011-08-23 5:08

Hi guys, i just started learning c, so i'm pretty much a noob. I was wondering i my code (which actually works) is messed, and things could have been done better
here it is:

#include <stdio.h>

main()
{
typedef struct giocatore {char player_name[30];} player;
int o;
printf("Inserire il numero di giocatori:");
scanf("%d", &o);
player no_player[o];

if (o == 1)
    printf("Avete scelto la modalità giocatore singolo\n");
else if ( o >= 1)
    printf("Avete scelto la modalità a %d giocatori\n", o);
else
    printf("inserire un valore corretto\n");

int i, e = 0;

for(i = 1; i <= o; i++, e++){
  printf("Inserire il nome del giocatore %d:", i);
  scanf("%s", &no_player[e].player_name);
  };
for(i = 0, e = 1; i < o; i++, e++){
  printf("Giocatore %d: %s\n",e , no_player[i].player_name);
  };
}

Name: Anonymous 2011-08-24 6:37

>>22

You can't do that for-loop variable declarement in C.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List