Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1026605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:06:32+00:00 2026-05-16T12:06:32+00:00

I was given task to generate random 80 byte keys and i have decided

  • 0

I was given task to generate random 80 byte keys and i have decided following strateges

in my computer sizeof(char)=1 so i have created array of english alphabetical letters

char *p=" ";
char a[0..26] and in cycle 


for (int  i=0;i<=80;i++){
   *(p+i)+= a[(rand()+100) % 26];
}

but it does not work it stops execution please help sorry if my code is stupid but i can’t think at this time otherwise
thanks
code

#include <iostream>
#include <string.h>
#include <cstdlib>
using   namespace std;
int main(){

    char *p=" ";
    char  a[]= { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
 for (int i=0;i<=80;i++){
        *(p+i)+=(a[(rand()+100)%26]);
    }

     cout<<p<<endl;


     return 0;

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:06:33+00:00Added an answer on May 16, 2026 at 12:06 pm

    Try this out:

    #include <iostream>
    #include <string.h>
    #include <cstdlib>
    using   namespace std;
    int main(){
        // ensure the target has enough memory for the key and a null terminator
        char p[81];
    
        // this string will do as nicely as the character array
        char a[] = "abcdefghijklmnopqrstuvwxyz";
    
        // no += here. I assign the random character directly to the target buffer
        for (int i=0;i<=80;i++)
            p[i] = a[rand()%26];
    
        // alternately, you can calculate a random English character with:
        // p[i] = rand()%26 + 'a';
        // which removes the need for the a[] buffer at all
    
        // don't forget to null-terminate
        p[80] = '\0'
    
        // output results
        cout<<p<<endl;
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Task: For a given position in 2D array generate list of surrounding positions located
The task is to generate a given number of numeric pins of a given
I have been given the task of adding functionality to an existing IIS 6.0
I have been given the task to design a database to store a lot
Guys I'm new to xml in Java. I have the following task. I need
I have been given a task to crawl / parse and index available books
I have the following weird requirement. I am given: A list of some method
I have been given the task of implementing a way to convert a string
Simple task: given that an article has many comments, be able to display in
I've been given the task of doing maintenance to a iOS application that uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.