473,385 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to Generate a large length of strings/numbers eg 4k byte

In C++ by using rand(); i am able to generate 10 numbers,
if i want to generate 4kbytes of numbers or strings
what i have to do, if anyone knows pls help me.
Thankyou
Oct 20 '06 #1
7 3850
In C++ by using rand(); i am able to generate 10 numbers,
if i want to generate 4kbytes of numbers or strings
what i have to do, if anyone knows pls help me.
Thankyou
U plz refer about Hashing algorithm It will give the solution
It is also pointer related
Oct 20 '06 #2
arne
315 Expert 100+
In C++ by using rand(); i am able to generate 10 numbers,
if i want to generate 4kbytes of numbers or strings
what i have to do, if anyone knows pls help me.
Thankyou
You may want to use a loop, like

Expand|Select|Wrap|Line Numbers
  1.     for( int i=0; i<1024; i++ ) {
  2.  
  3.         cout << rand() << endl;
  4.     }
  5.  
This example will produce 1024 random numbers. On most systems, an int is 4 bytes long, so you have 4kBytes of random numbers in total. Is that what you would like to do?
Oct 20 '06 #3
Thanks for ur replay
pls help me how to generate string(character)
by using rand() i able to generate only numbers,
how to generate random characters.
pls help me.


thank you,
Oct 26 '06 #4
arne
315 Expert 100+
Thanks for ur replay
pls help me how to generate string(character)
by using rand() i able to generate only numbers,
how to generate random characters.
pls help me.


thank you,
One possibility is to establish a mapping between your random numbers and the characters. Hint: Use the % function and remember that 'A' has ASCII value 65, 'B' has value 66, and so on ...
Oct 26 '06 #5
Pls can u give me one example
I am now learning VC,
idont know much about this,


Thankyou,
Oct 27 '06 #6
arne
315 Expert 100+
Pls can u give me one example
I am now learning VC,
idont know much about this,


Thankyou,
Consider something like the following code snippet:

Expand|Select|Wrap|Line Numbers
  1. int ic;
  2. ic = 65 + (rand() % 26);
  3. cout << (char)ic << endl;
  4.  
This code defines an int called 'ic'.
rand() % 26 delivers random numbers in the range [0,..,25].
'ic' gets assigned such a random number plus the offset 65. So 'ic' has numbers in the rang [65, .. 90]. By casting 'ic' to a char in line 3, the program prints letters between 'A' (ASCII code 65) and 'Z' (ASCII code 90).

Hope that helps :)
Oct 27 '06 #7
Thank you very much for ur help,
now i want one more help,

I am creating a text file
How to Save a File(text file) in VC++
If i click the command button, save dialog box should open,
user should give a name & save/Saveas the text file.

By using i am able to open a OPEN DIALOG BOX
CFIleDialog m_samp(TRUE);
m_samp.Domodal();
To save or Save as How to do.



pls help me..........


Thanks
Oct 27 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
4
by: darin dimitrov | last post by:
Hello, I need help with an algoritm that given a set of "n" distinct numbers will generate all the possible permutations of fixed length "m" of these numbers WITH repetitions (a total of n^m...
0
by: zhimin | last post by:
Hi, I'm writing a program to send large file(100m) through dotnet using TCPListener & TCPClient, I'm sending the file with a ask and response loop: 1. Client send a flag 1 to server indicate it...
10
by: Crirus | last post by:
Is there a function that return some random ID like string alphanumeric? Like this: A35sDsd1dSGsH Thanks Crirus
17
by: Sri | last post by:
How do you add an n-bit number in C? Regards, Sri
15
by: Orchid | last post by:
Hello, I am looking to generate a unique ID field on MS. Access. The ID is with 10 digits with the combination of 5 Letters from the 26 letters and 5 Numbers from 1 to 9. The letters and numbers...
9
by: Omatase | last post by:
I have a set of about 6 or so strings that I need to use to generate a unique hash. This hash will become the unique key in a database so the hash has to be the same each time I gen it for any 1...
3
by: dohyohdohyoh | last post by:
I have a programming question to generate an ordered list of alphanumeric strings of length 4. two alphabets rest numberst, etc. EG 0000-9999 then A000-Z999 then AA00 to ZZ99 then AAA0 - ZZZ9...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.