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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:30:34+00:00 2026-05-19T04:30:34+00:00

I know I shouldn’t be using that function, and I don’t care. Last time

  • 0

I know I shouldn’t be using that function, and I don’t care. Last time I checked the spec for strcat, it said something along the lines of updating the first value as well as returning the same.

Now, this is a really stupid question, and I want you to explain it like you’re talking to a really stupid person.

Why won’t this work?

char* foo="foo";
printf(strcat(foo,"bar"));

EDIT: I don’t know the difference between char[] and char*. How would I allocate a string of 255 characters?

EDIT 2: OK, OK, so char[number] allocates a string of that many bytes? Makes sense. Thanks.

EDIT 3: Also, how would I use a character array without declaring it? Would I typecast it as char[255]?

EDIT 4: strcat((char[256])”foo”,”bar”) returns an error. I’m about fed up with C.

EDIT 5: So does strcat((char[256])”foo”,(char[])”bar”).

EDIT 5:

char[256] foo="bar";

Real smooth. “identifier expected”

  • 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-05-19T04:30:34+00:00Added an answer on May 19, 2026 at 4:30 am
    char* foo="foo";
    

    is a string literal.

    It can’t be modified. Do char [] foo = "foo"; instead but keep in mind that using strcat like that, will cause problems in this case cause it will write in memory it shouldn’t when trying to strcat “bar” so you should try something like char foo[30] = "foo";

    Edit: The typecasting you do… sorry I do not have so many brain cells as to try to explain you what you are trying to do. I can only tell you it is wrong. you need to provide a memory location so strcat() can work.

    Try that :

    int main()
    {
        char foo[255]="foo";
        printf("%s",strcat(foo,"bar"));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that we shouldn't being using the registry to store Application Data anymore,
Are there any open-source libraries that all programmers should know about? I'm thinking something
I know I shouldn't be outputting things directly in PHP, but using a template
I know this shouldn't be that hard, but I couldn't find the answer on
Does anyone know why the last alert in the code below complains that a
I'd like to know when i should and shouldn't be wrapping things in a
What are some key UI design tips that every developer should know? While there
I get the feeling this is probably something I should know but I can't
Should I seal all classes I know shouldn't ever be used as a base
I know I shouldn't be exposing a List<T> in a property, but I wonder

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.