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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:21:38+00:00 2026-06-03T22:21:38+00:00

ANSWER: I wasn’t properly initializing variables. I need to remember how pointer declarations work

  • 0

ANSWER: I wasn’t properly initializing variables.

I need to remember how pointer declarations work in C.

This chunk of code is supposed to take in some command line arguments in the format of:

./foo 1 2 3 4 5 6 7 8 9 10 … (any reasonable number of arguments so long as they’re divisible by 5

My plan is to have 5 int arrays of variable size to store the arguments for use in logic later. So if I have 10 arguments, I’d have 5 2-int arrays, and so on.

int* IP1, IP2, BID, PN, EID;
int i;

if((argc < 2) || ((argc-1) % 5) != 0)
{ 
   /* Some error statements */
}

IP1 = (int*)malloc(argc-1);
IP2 = (int*)malloc(argc-1);  //This is line 26
BID = (int*)malloc(argc-1);
PN = (int*)malloc(argc-1);
EID = (int*)malloc(argc-1);

for(i = 0; i < argc-1; i+=5){
  IP1[i] = argv[i+1];
  IP2[i] = argv[i+2];        //This is line 33
  BID[i] = argv[i+3];
  PN[i] = argv[i+4];
  EID[i] = argv[i+5];
  printf("%d\t", i);
}

Problem is, I get these weird errors

>cc foo.c -o foo
foo.c: In function ‘main’:
foo.c:26: warning: assignment makes integer from pointer without a cast
foo.c:27: warning: assignment makes integer from pointer without a cast
foo.c:28: warning: assignment makes integer from pointer without a cast
foo.c:29: warning: assignment makes integer from pointer without a cast
foo.c:33: error: subscripted value is neither array nor pointer
foo.c:34: error: subscripted value is neither array nor pointer
foo.c:35: error: subscripted value is neither array nor pointer
foo.c:36: error: subscripted value is neither array nor pointer

And I have no idea what they’re supposed to be or represent. I’ve looked it up and nothing’s helped so far. I was hoping y’all could.

EDIT: For the record I tried commenting out lines 26-30 and 33-37 and it compiles fine. Just thought I’d add that for posterity.

  • 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-03T22:21:39+00:00Added an answer on June 3, 2026 at 10:21 pm

    This:

    int* IP1, IP2, BID, PN, EID;
    

    is the same as this:

    int *IP1;
    int IP2;
    int BID;
    ...
    

    You want this:

    int *IP1, *IP2, *BID, *PN, *EID;
    

    But more generally, try to avoid declaring multiple variables on the same line.

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

Sidebar

Related Questions

I wasn't able to get an answer to this and i need it badly!
Answer solved in edit below I had this piece of code Dictionary<Merchant, int> remaingCards
I'm a C++ newbie, but I wasn't able to find the answer to this
This has been asked , but wasn't answered. The answer (use /warn:1 ) doesn't
hope this wasn't asked already, but I can't find an answer. I got a
I read this question/answer however there wasn't any mention of it being a "bad
I tried to find a question that would answer to this question but wasn't
I wasn't able to find an answer anywhere about this seemingly simple topic: is
I wanted to post this question and answer because I wasn't able to find
Please forgive my ignorance, but I wasn't able to find an answer elsewhere. I

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.