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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:37:03+00:00 2026-06-13T22:37:03+00:00

Why this code isn’t working. Just trying to check if the user input is

  • 0

Why this code isn’t working. Just trying to check if the user input is the same as a password

char *pass;

printf("Write the password: ");
scanf("%s", pass); // Because is a pointer the & is out ?


if( strcmp( pass , "acopio") == 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-13T22:37:04+00:00Added an answer on June 13, 2026 at 10:37 pm

    You’ve not actually allocated any space to put data. Defining a pointer just defines a variable that can hold the address of a block of data, it doesn’t allocate the block.

    You have a couple of options, allocate dynamic memory off the heap to write into and make the pointer point to it. Or use statically allocated memory on the stack and pass the address of it to your calls. There’s little benefit to dynamic memory in this case (because it’s temporary in use and small). You would have more work to do if you used dynamic memory – you have to make sure you got what you asked for when allocating it and make sure you’ve given it back when you’re done AND make sure you don’t use it after you’ve given it back (tricky in a big app, trust me!) It’s just more work, and you don’t seem to need that extra effort.

    The examples below would also need significant error checking, but give you the general idea.

    e.g.

    char *pass = malloc (SOMESIZE);
    
    printf("Write the password: ");
    scanf("%s", pass);
    
    
    if( strcmp( pass , "acopio") == 0)
    

    or

    char pass[SOMESIZE];
    
    printf("Write the password: ");
    scanf("%s", pass);
    
    
    if( strcmp( pass , "acopio") == 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code isn't for anything in particular. I'm just trying to successfully get the
I'm struggling with trying to find out why this code isn't working for me.
I am stumped as to why this code isn't working as per the comment
I have looked all over and cannot figure out why this code isn't working.
Why isn't this code working? I've been stuck on this for 2 days. public
This isn't cross-platform code... everything is being performed on the same platform (i.e. endianess
This code isn't working. It doesn't raise an exception or even do anything visible.
I'm not sure why this code isn't working. . . I can't find the
Why this code isn't working ? (This is not the actual code, but a
I apologize ahead of time if this code isn't formatted correctly, trying to paste

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.