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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:21:06+00:00 2026-05-17T17:21:06+00:00

I want the user to enter a 4 digit number and the program must

  • 0

I want the user to enter a 4 digit number and the program must tell what that 4 digit number was i.e generate that 4 digit number by Brute force attack.But at the line mentioned below the compiler says invalid indirection.I would also like to have some comments about they way I am implementing it,is it a good practise?

#include<stdio.h>
void BruteForceAttack(int *arr);
int main()
{
 int *arr,i;
 printf("Enter 4 digits ,press enter after entring each digit:\n");
 for(i=0;i<4;i++)
 scanf("%d",arr+i);
 BruteForceAttack(arr);
 getchar();
 return 0;
}
void BruteForceAttack(int *arr)
{
 int i,j,k,l;
 for(i=0;;i++)
 {
  for(j=0;;j++)
  {
   for(k=0;;k++)
   {
    for(l=0;;l++)
    {
      if((*(arr+0)==i)&&(*(arr+1==j))&&(*(arr+2==k))&&(*(arr+3)==l))   /*Here the compiler says invalid indirection*/
     {
      printf("The number is %d%d%d%d",i,j,k,l);
      return;
     }
    }
   }
  }
 }
}
  • 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-17T17:21:06+00:00Added an answer on May 17, 2026 at 5:21 pm

    Total of 3 problems:

    Problem 1:

    Your arr is a dangling pointer and you are dereferencing it in scanf.

    You need:

    int arr[4]; 
    

    in place of

    int *arr;
    

    Problem 2:

    The comparison involving j and k is incorrectly paranthesized:

    &&(*(arr+1==j))&&(*(arr+2==k))
    

    should be

    &&(*(arr+1)==j)&&(*(arr+2)==k)
              ^              ^
    

    Problem 3:

    Even with above 2 fixes your program will run into infinite loop, because your for loops have no terminating conditions.

    Since you are asking user to enter 4 digits, all your loop should go from 0 till 9 as:

    for(i=0;i<10;i++)
            ^^^^^
    

    Add similar check for other 3 loops aswell.

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

Sidebar

Related Questions

in my web application i want to validate that user can enter only digits
I have a textbox that I want the user to enter an integer in.
i want something like this the user enter a website link i need check
I want to open a save file dialog, have the user enter a filename,
I want to build a site where the user can enter text and format
I am presenting the user with a field that displays the number keyboard and
i have a EditText in android in which i want the user to enter
I have a form that lets the user enter in some text. It will
I want to count the number of bits in a binary number that are
I want to first form a 3-digit code once a user enters some input

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.