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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:10:27+00:00 2026-06-17T06:10:27+00:00

I am new to C++ . I am writing following simple code. I wanted

  • 0

I am new to C++ . I am writing following simple code. I wanted to pass the character[40] into a function and then get the same as output.
If i put a debug at following point.
strcpy_s(x,100,tester);

But it only takes “This” if i write “This is sent at the output”. Can anyone please point out what am i missing and whats the reason for only accepting few characters.

// BUSTesting.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include "resource.h"

int testFunction(char* tester);
int _tmain()
{

    char m[40];
    std::cin>>m;
    testFunction(m);
}
int testFunction(char* tester)
{

    char x[100] ;
    memset(x,100,sizeof(x));
    strcpy_s(x,100,tester);
    std::cout<<x;
    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-06-17T06:10:29+00:00Added an answer on June 17, 2026 at 6:10 am

    operator>> will stop consuming input at first whitespace character. An alternative would be to use cin.getline() to prevent processing of input due to whitespace.

    Note to initialize an array and avoid memset():

    char x[100] = "";
    

    Recommend std::string and std::getline() which avoids specifying a maximum number of characters to read from the input stream (avoiding potential buffer overrun problems with fixed sized arrays).

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

Sidebar

Related Questions

I'm writing an XML file with the following code: Source source = new DOMSource(rootElement);
I have the following code with a simple class and a method for writing
I am fairly new to writing C code and I am sure I have
I am fairly new to writing code, but I played around with some chrome
I'm finding myself repeatedly writing and rewriting the following kind of code: my %default
I am writing a simple AJAX code as a way to learn the basics
Ive been writing a simple jquery function that turns a div with a list
Writing a code that does the following: Adds a mouse listener to a web-page
I was just writing some simple code and I noticed that using document.writeln doesn't
I'm writing code to programmatically run git commands and learning git at the same

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.