•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 397,798 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,345 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 1913 | Replies: 6
![]() |
•
•
Join Date: Oct 2006
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
Hi guy's i was wondering if any one can help i wat to make a random file generator which will be able to create random file's with random string's in them also i wilkl have to be able to control the file extension..Its for a file fuzzer im working on any help would be much apriciated also would like to use cygwin..Random string's like
AAAAAAAAAAAAABBBBBBBBBBBBBCCCCCCCCCCCCCCCCCDDDDDDEEEEE//////\\\\----===\\\\|=
CCCCCCCDDDDEEEEEEEEWWWWWWAAAAAAAAAAAA[[[[[]]]]
so the aboved is just an example i want to fill the file with any thing realy i want to let the program decide but i also will ne to control the amount of byte's that is wrote to the file basicaly every thing will be random so it will print 40 file's of a file extension i chose and write diffrent string's to the file any help would be grate:eek: .
AAAAAAAAAAAAABBBBBBBBBBBBBCCCCCCCCCCCCCCCCCDDDDDDEEEEE//////\\\\----===\\\\|=
CCCCCCCDDDDEEEEEEEEWWWWWWAAAAAAAAAAAA[[[[[]]]]
so the aboved is just an example i want to fill the file with any thing realy i want to let the program decide but i also will ne to control the amount of byte's that is wrote to the file basicaly every thing will be random so it will print 40 file's of a file extension i chose and write diffrent string's to the file any help would be grate:eek: .
Any leads you have got so far, post your code or your algorithm and we will help you out. Posting out what you want to do is no good to us in helping you.
PS: If you want to write random data, use the normal random function which will generate random numbers between 1 and 128. Cast those numbers to "char" data type and write them to your file. This way you will get random chars in your data file.
PS: If you want to write random data, use the normal random function which will generate random numbers between 1 and 128. Cast those numbers to "char" data type and write them to your file. This way you will get random chars in your data file.
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int
main (int argc, char *argv[])
{
/* Simple "srand()" seed: just use "time()" */
unsigned int iseed = (unsigned int)time(NULL);
srand (iseed);
/* Now generate 5 pseudo-random numbers */
int i;
for (i=0; i<5; i++)
{
printf ("rand[%d]= %u\n",
i, rand ());
}
return 0;Also Maybe the foll:
random number generate and outpt to file
Random number detailed theory
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
•
•
Join Date: Oct 2006
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
~s.o.s~ what can i say man you are great very much apriciated m8..I know alot of language's a bit of c c++ but i know more of perl python ruby any way's if i have any further question i will post cant thank you enough m8..Just got to find out haw i can restrict the file size also and write to multiple file's instead of just the one..
Last edited by muhaa : Oct 19th, 2006 at 6:17 am.
Create multiple file streams, and what you are doign to one file, make that applicable to multiple files.. simple.
FILE *output1; FILE* output2; FILE* output3; // ...... // do something with these files // close the above files
Last edited by ~s.o.s~ : Oct 19th, 2006 at 11:38 am.
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
•
•
Join Date: Oct 2006
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
Ok thnx man this is what i have got so far using your examples to help
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int rrand(int min,int max)
{
static int init = 0;
int ret;
if(init==0){
srand(time(NULL));
init=1;
}
ret = (rand() % (max-min+1) + min);
return ret;
}
int main(void)
{
int i, r;
for(i=0;i<20;i++){
r = rrand(65,90); /* 65 = A, 90 = Z. get it? */
printf("Random char = %c\n",r);
}
return 0;
}
Last edited by Salem : Oct 19th, 2006 at 1:05 pm. Reason: Changed inlinecode to code for multi-line code
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
Similar Threads
- C++ File Generator (C++)
- Header file Generator (C)
Other Threads in the C Forum
- Previous Thread: reversing long integers,, newbie,, pls. help
- Next Thread: List of open files



Linear Mode