User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Oct 2006
Posts: 9
Reputation: muhaa is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
muhaa muhaa is offline Offline
Newbie Poster

Cygwin file generator

  #1  
Oct 18th, 2006
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: .
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,806
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 338
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Cygwin file generator

  #2  
Oct 18th, 2006
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.
"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."
Reply With Quote  
Join Date: Oct 2006
Posts: 9
Reputation: muhaa is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
muhaa muhaa is offline Offline
Newbie Poster

Re: Cygwin file generator

  #3  
Oct 18th, 2006
Hi thnx for the rely i am just starting to code the application any chance you got any link's that might give me a good start thnx in advance.
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,806
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 338
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Cygwin file generator

  #4  
Oct 18th, 2006
#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."
Reply With Quote  
Join Date: Oct 2006
Posts: 9
Reputation: muhaa is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
muhaa muhaa is offline Offline
Newbie Poster

Re: Cygwin file generator

  #5  
Oct 19th, 2006
~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.
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,806
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 338
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Cygwin file generator

  #6  
Oct 19th, 2006
Originally Posted by muhaa View Post
..write to multiple file's instead of just the one..

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."
Reply With Quote  
Join Date: Oct 2006
Posts: 9
Reputation: muhaa is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
muhaa muhaa is offline Offline
Newbie Poster

Re: Cygwin file generator

  #7  
Oct 19th, 2006
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 5:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC