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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:26:23+00:00 2026-05-26T23:26:23+00:00

I have created the following program which allows a user to guess a word

  • 0

I have created the following program which allows a user to guess a word 3 times before ending the program. I’m using a function to read the users input. When I compile the program I get the error ‘expected expression before char’. Some feedback would be great thanks!

#include <stdio.h>
#include <string.h>

void get_user_input(char *guess[10]);

void get_user_input(char *guess[10])
{ 
     printf("Please guess the word: \n");
     scanf("%s", guess);
}

int main(void)
{
     const char secret[10] = "pink";
     char guess[10];
     int i;

     for (i=0; i < 3; i++)
     {
         get_user_input(char *guess[10]);

         if (strcmp(secret, guess)==0)
         {
             printf("Your guess was correct");
             return 0;
         }
         else
         {
             printf("Your guess was incorrect. Please try again\n");
         }
     } 
     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-05-26T23:26:23+00:00Added an answer on May 26, 2026 at 11:26 pm

    You have an extra char here:

    for (i=0; i < 3; i++)
    {
        get_user_input(char *guess[10]);
    

    Just get rid of it. You just need to pass the variable in.

    get_user_input(guess);
    

    EDIT :

    The other problem seems to be this function:

    void get_user_input(char *guess[10]);
    

    change it to this:

    void get_user_input(char *guess)
    { 
     printf("Please guess the word: \n");
     scanf("%s", guess);
    }
    

    and it should work. However, be aware that you run the risk of overrunning your guess array.

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

Sidebar

Related Questions

I have created a following program in which I wish to poll on the
I have created some application, which is reading from System.in using the following method:
I have a created a following renderer which renders the JTree with checkboxes and
I have created a certificate using the following SSL command: makecert -r -pe -n
I am currently trying to program a batch script which allows the user to
I have created following rule in the .htaccess file located at the root of
I have created the following stored procedure.. CREATE PROCEDURE [dbo].[UDSPRBHPRIMBUSTYPESTARTUP] ( @CODE CHAR(5) ,
I have created the following C library for reading an image: typedef struct {
I have created the following project structure for my new asp.net mvc project any
I have created the following vsct file xml. <?xml version=1.0 encoding=utf-8?> <CommandTable xmlns=http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable xmlns:xs=http://www.w3.org/2001/XMLSchema>

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.