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

  • Home
  • SEARCH
  • 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 7723227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:23:23+00:00 2026-06-01T04:23:23+00:00

Possible Duplicate: In C++, Why can't I write to a string literal while I

  • 0

Possible Duplicate:
In C++, Why can't I write to a string literal while I can write to a string object?

I’m having my first experience with wchar_t strings and I’m having a lot of trouble. Each time I try to access a character in an wchar_t* the program crashes with segmentation fault. How should I do if I want to replace one character in the string with another? But when deleting a character from the end of the string?

wchar_t * my_string[] = L"Hello";
my_string[0] = L'Y'; // Should be "Yello". Instead, gives segmentation fault

[edit]
Doesn’t matter, I’ve just made a fool out of myself. I’ll check elsewhere on the internet. It’s my fault, I shouldn’t be bothering you with such silly questions…

  • 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-01T04:23:24+00:00Added an answer on June 1, 2026 at 4:23 am

    You didn’t supply much information, but, since you talk about segmentation fault, the most common errors derived from the fact that memory management functions usually works on bytes while wchar_t has a size greater than 1.

    When doing pointer arithmetic over char, the sizeof(char) is almost never taken in count, since it is 1 by definition. But wchar_t is wider, hence where bytes length are required, a multiplication of sizeof(wchar_t) must be placed.

    [EDIT] Sorry but the sample has nothing to do with wchar_t itself:

    wchat_t* my_string[] is an arry of wchar_t-pointers, the first of which is made to point to “Hello”, and the other are left uninitialized. Just remove the *.

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

Sidebar

Related Questions

Possible Duplicate: Can you write object oriented code in C? I'm wondering if it's
Possible Duplicate: Can you write object oriented code in C? Hi, can someone point
Possible Duplicate: Can you write object oriented code in C? Hi! Just for the
Possible Duplicate: C++ concatenate string and int Hi, In C# I can write like
Possible Duplicate: Can Read-Only Properties be Implemented in Pure JavaScript? I have an Object
Possible Duplicate: Oracle DB: How can I write query ignoring case? I have an
Possible Duplicate: how can I convert String to Int ? Hi, I have the
Possible Duplicate: How can I write a Java application that can update itself at
Possible Duplicate: Hash Function .NET hi, I should write an app that take string
Possible Duplicate: From the string name of a class, can I get a static

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.