Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main(int argc, char *argv[]){
- if (argc == 1){
- fprintf(stderr,"Adjon meg egy számot!\n");
- return 0;
- }
- FILE *f = fopen("szamok.txt","w+");
- int n = atoi(argv[1]);
- char c;
- srand(time(NULL));
- int szam;
- for (int i = 0; i < n; i++){
- fprintf(f,"%d\n",rand()%(50-2+1)+2);
- }
- fseek(f,1,SEEK_SET);
- FILE *g = fopen("szamok2.txt","w+");
- while (1){
- fscanf(f,"%d",&szam);
- if (feof(f)) break;
- fprintf(g,"%d\n",szam);
- }
- fclose(f);
- fclose(g);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement