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 9038061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:23:52+00:00 2026-06-16T09:23:52+00:00

int lineInputs = 0; cin >> lineInputs; int whatever = 0; char* myArray =

  • 0
int lineInputs = 0;

cin >> lineInputs;

int whatever = 0;

char* myArray = new char[arrayElements*lineInputs];

int j =0;

for(int i = 0; i < lineInputs; i++)
{
        cin >> whatever;
    for(j; j<total; j+=39)
    {
        for(int nom=0; j<arrayElements; nom++)
        {
            cin >> myArray[j];
        }
    }

}

In my forloop say i have lineInputs = 4 and total = 156

Meaning 4 times we do this, we want to insert 156 chars into my array. But we want to make it so that every 40 characters we continue entering the array.

Bsically we need to insert this input into the array but i feel like my forloops are messed up. This will be the input

4 
1 
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH 
2 
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 
3 
HHTTTHHTTTHTHHTHHTTHTTTHHHTHTTHTTHTTTHTH 
4 
HTHTHHHTHHHTHTHHHHTTTHTTTTTHHTTTTHTHHHHT

The first line 4 meaning 4 of these 40 character lines. And the number above the character lines just signifying line 1 2 3 4 ect.

How can i attempt this right?

So the array would basically look like this.

HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTHHTTTHHTTTHTHHTHHTTHTTTHHHTHTTHTTHTTTHTHHTHTHHHTHHHTHTHHHHTTTHTTTTTHHTTTTHTHHHHT

  • 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-06-16T09:23:53+00:00Added an answer on June 16, 2026 at 9:23 am

    You are making the same fundamental mistake you made in your other question, which is to fail to treat the input array correctly. You are repeatedly reading into the first 40 characters of myArray. What you need to do is read the first line into the first 40 characters, the second line into characters 40 to 79, etc.

    Better yet, make it a two dimensional array so that you don’t have to muck around with computing the indices.

    Even better, make it an array of std::string rather than an array of char.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say i have an array char myArrray[5] = {'T','T','T','T','T'} And i want to check
int main() { string line; char buff[10]; for(int i=0; i<10;i++) { cin.get(buff[i]); cout.put(buff[i]); if(i==10)
int[] alist = new int [3]; alist.add(apple); alist.add(banana); alist.add(orange); Say that I want to
int main(int argc, char **argv){ // If the user does not have the right
int main(void) { char testStr[50] = Hello, world!; char revS[50] = testStr; } I
int* p_bob = new int; *p_bob = 78; The above code makes sense to
int main() { char *p,c; for(p=Hello World;c=*p;++p) { printf(%c,c); } } In the above
int main(int argc, char* argv[]) { ofstream file; file.open(Motion.dat); int frame_number = 0; CvCapture*
int PlayerAmount = 10; int CurrentPlayer = 0; Player[] player = new Player[PlayerAmount]; while
int port = 18000; DatagramSocket serverSocket = new DatagramSocket(port); byte[] receiveData = new byte[8];

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.