Okay. So I've got some code, which I want to compile in C99 standard because of an initializer inside of for() loop. And I've to use rand()'s and srand()'s. Here's my code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char** argv)
{
int n=atoi(argv[1]);
char name[n+1];
srand(time(NULL));
for(int i=0; i<n; i++)
{
name[i]='a'+rand()%26;
printf("%c", name[i]);
}
printf("\n");
}
And I'd compile it with: gcc random.c -o random -std=C99 - that eliminates a problem with for() (int i=0 inside it).
And when I make it give me this:
How can I actually make it run?
Aucun commentaire:
Enregistrer un commentaire