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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:15:42+00:00 2026-06-12T02:15:42+00:00

I have written a C program. It compiles and works fine on DevC on

  • 0

I have written a C program. It compiles and works fine on DevC on Windows 7.
But when I compile it on Linux mint (using ‘gcc main.c’ command) it does not compile and give errors. These errors are not shown while compiling on Windows 7. So nothing must be wrong on Linux as well! How to compile it on Linux through gcc?

C Code:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
   char command[100];

   printf("Enter the command:");
   scanf("%[^\t\n]", &command);
   printf("%s\n", command);
   strchr(command, '&');

   printf("%i", strchr(command, '&'));

   system("PAUSE"); 

   return 0;
}

Errors:

mint@mint ~ $ gcc ass1/main.c
ass1/main.c: In function 'main':
ass1/main.c:8:5: warning: format '%[^   
' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat]
ass1/main.c:11:3: warning: incompatible implicit declaration of built-in function 'strchr' [enabled by default]
ass1/main.c:13:5: warning: format '%i' expects argument of type 'int', but argument 2 has type 'char *' [-Wformat]
  • 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-12T02:15:43+00:00Added an answer on June 12, 2026 at 2:15 am

    Those aren’t errors, they’re warnings. Your code should have still compiled.

    The first warnings is because you’re passing &command to scanf, which is of type char (*)[100], and the specifier %s expects an argument of type char *. All you simply need to do is pass command to scanf (without the &), since a char array will decay into a char* when passed to a function.

    You’ll probably find that the code still works, with command and &command both referring to the same address (printf("%p %p", command, &command);).

    The second warning is due to you forgetting to include <string.h>, which declares strchr. Since the compiler can’t find the declaration, it implicitly generates one, which doesn’t turn out to match the real one.

    Lastly, strchr returns a char*, and the specifier %i is intended to be used for ints. If you want to print out an address using printf, use the %p specifier.

    You should also probably avoid system("PAUSE"); (which won’t work on Linux), and replace it with a function that waits for user input.

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

Sidebar

Related Questions

I have a program which writes its output using ofstream. Everything works perfectly fine
I have written a program in VB6. When I compile it and send it
I have a program written in C++, on Linux, compiled with -g. When I
I have a program that is written in Ada, and I need to compile
I have written a program that uses qhttp to get a webpage. This works
I have written this program, which sorts some ints using a functor: #include<iostream> #include<list>
Visual Studio C++ 2008 / GCC 4.4.2 I have written a program to run
Using the ndk I have compiled a code written in C. The program is
I'm using glade to designa a interface for my program written in C but
I have written this program that has a main function, inside which, I am

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.