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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:09:51+00:00 2026-06-17T04:09:51+00:00

omg im am so confused right now what is wrong here and what can

  • 0

omg im am so confused right now

what is wrong here and what can i do to fix it

EDIT: omg i am so sorry…i am just so fluctuated right now that i cant even ask a question

i want to assign 10 inputed char strings to a pointer array.

using namespace std;

int main(int argc, char *argv[])
{
    char *mess[10];
    int i = 0;

for (; i < 10; i++)
{                 
    cout << "Enter a string: ";   
    cin.getline(mess[i], 80);
}

for (i = 0; i < 10; i++)
    cout << mess[i];

system("PAUSE");
return EXIT_SUCCESS;
}
  • 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-17T04:09:53+00:00Added an answer on June 17, 2026 at 4:09 am

    What you want is probably declare your array this way:

    char mess[10][80];
    

    As you are reading up to 80 characters from getline.

    Your current implementation builds an array of 10 char* which are never initialized to point on allocated buffers.

    A much safer way would be to use std::string as the buffer size will be handled for you. A simple change to:

    #include <iostream>
    #include <string>
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        std::string mess[10];
        int i = 0;
    
        for (; i < 10; i++)
        {                 
            cout << "Enter a string: ";   
            cin >> mess[i];
        }
    
        for (i = 0; i < 10; i++)
            cout << mess[i] << endl; // you probably want to add endl here
    
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    

    Should give you what you want.

    EDIT

    If you absolutely need char * (which is not a good idea), here’s what you’re looking for:

    #include <iostream>
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        char* mess[10];
        int i = 0;
    
        for (; i < 10; i++)
        {                 
            cout << "Enter a string: ";   
            mess[i] = new char[80]; // allocate the memory
            cin.getline(mess[i], 80);
        }
    
        for (i = 0; i < 10; i++)
        {
            cout << mess[i] << endl;
            delete[] mess[i]; // deallocate the memory
        }
    
        // After deleting the memory, you should NOT access the element as they won't be pointing to valid memory
    
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OMG! What am I doing wrong? declare @WTF TABLE ( OrderItemId int ) SELECT
How can I check if $something['say'] has the value of 'bla' or 'omg' ?
Regarding the specifications here: http://www.omg.org/technology/documents/formal/uml.htm What is the difference between without and with change
I can't seem to find one on the OMG's website. I need this document
This is a one very newbie question but i just can't figure out where
I really just need to be able to validate that the XMI file I'm
I can make the best kick-ass web apps all day long, but OMG I
EDIT omg I clearly should take a break... logcat gives these errors and as
I wrote an xml parser that parses ASCII files, but I need now to
var date = new Date();//Mon Mar 15 2010 12:40:05 GMT+0300 (MSK) var omg =

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.