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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:42:01+00:00 2026-05-11T07:42:01+00:00

So I have a program that makes char* stuff lowercase. It does it by

  • 0

So I have a program that makes char* stuff lowercase. It does it by iterating through and manipulating the ascii. Now I know there’s probably some library for this in c++, but that’s not the point – I’m a student trying to get a grasp on char*s and stuff :).

Here’s my code:

#include <iostream>  using namespace std;  char* tolower(char* src);  int main (int argc, char * const argv[]) {     char* hello = 'Hello, World!\n';      cout << tolower(hello);     return 0; }  char* tolower(char* src) {     int ascii;     for (int n = 0; n <= strlen(src); n++)     {         ascii = int(src[n]);         if (ascii >= 65 && ascii <= 90)         {             src[n] = char(ascii+32);         }     }      return src; } 

( this is not for an assignment 😉 )

It builds fine, but when I run it it I get a ‘The Debugger has exited due to signal 10’ and Xcode points me to the line: ‘src[n] = char(ascii+32);’

Thanks!

Mark

  • 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. 2026-05-11T07:42:01+00:00Added an answer on May 11, 2026 at 7:42 am

    Yowsers!

    Your ‘Hello World!’ string is what is called a string literal, this means its memory is part of the program and cannot be written to.

    You are performing what is called an ‘in-place’ transform, e.g. instead of writing out the lowercase version to a new buffer you are writing to the original destination. Because the destination is a literal and cannot be written to you are getting a crash.

    Try this;

    char hello[32]; strcpy(hello, 'Hello, World!\n'); 

    Also in your for loop, you should use <, not <=. strlen returns the length of a string minus its null terminator, and array indices are zero-based.

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

Sidebar

Ask A Question

Stats

  • Questions 102k
  • Answers 102k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your question is confusing. Are you asking what this does:… May 11, 2026 at 8:15 pm
  • Editorial Team
    Editorial Team added an answer The problem is not dependency related but source related. If… May 11, 2026 at 8:15 pm
  • Editorial Team
    Editorial Team added an answer You could use JOrbis library to play back OGG music.… May 11, 2026 at 8:15 pm

Related Questions

We are all taught that you MUST free every pointer that is allocated. I'm
So I have a couple of functions that work with a string type I
So the teacher has posed this assignment: You have been hired by the United
So I am currently learning C++ and decided to make a program that tests

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.