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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:26:13+00:00 2026-05-11T05:26:13+00:00

So I have some code that looks like this: int a[10]; a = arrayGen(a,9);

  • 0

So I have some code that looks like this:

int a[10]; a = arrayGen(a,9); 

and the arrayGen function looks like this:

int* arrayGen(int arrAddr[], int maxNum) {     int counter=0;     while(arrAddr[counter] != '\0') {         arrAddr[counter] = gen(maxNum);         counter++;     }     return arrAddr; } 

Right now the compilier tells me ‘warning: passing argument 1 of ‘arrayGen’ makes integer from pointer without a cast’

My thinking is that I pass ‘a’, a pointer to a[0], then since the array is already created I can just fill in values for a[n] until I a[n] == ‘\0’. I think my error is that arrayGen is written to take in an array, not a pointer to one. If that’s true I’m not sure how to proceed, do I write values to addresses until the contents of one address is ‘\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. 2026-05-11T05:26:14+00:00Added an answer on May 11, 2026 at 5:26 am

    The basic magic here is this identity in C:

    *(a+i) == a[i] 

    Okay, now I’ll make this be readable English.

    Here’s the issue: An array name isn’t an lvalue; it can’t be assigned to. So the line you have with

    a = arrayGen(...) 

    is the problem. See this example:

    int main() {     int a[10];      a = arrayGen(a,9);      return 0; } 

    which gives the compilation error:

    gcc -o foo foo.c foo.c: In function 'main': foo.c:21: error: incompatible types in assignment  Compilation exited abnormally with code 1 at Sun Feb  1 20:05:37 

    You need to have a pointer, which is an lvalue, to which to assign the results.

    This code, for example:

    int main() {     int a[10];     int * ip;      /* a = arrayGen(a,9);  */     ip = a ; /* or &a[0] */     ip = arrayGen(ip,9);      return 0; } 

    compiles fine:

    gcc -o foo foo.c  Compilation finished at Sun Feb  1 20:09:28 

    Note that because of the identity at top, you can treat ip as an array if you like, as in this code:

    int main() {     int a[10];     int * ip;     int ix ;      /* a = arrayGen(a,9);  */     ip = a ; /* or &a[0] */     ip = arrayGen(ip,9);      for(ix=0; ix < 9; ix++)         ip[ix] = 42 ;      return 0; } 

    Full example code

    Just for completeness here’s my full example:

    int gen(int max){     return 42; }  int* arrayGen(int arrAddr[], int maxNum) {     int counter=0;     while(arrAddr[counter] != '\0') {         arrAddr[counter] = gen(maxNum);         counter++;     }     return arrAddr; }  int main() {     int a[10];     int * ip;     int ix ;      /* a = arrayGen(a,9);  */     ip = a ; /* or &a[0] */     ip = arrayGen(ip,9);      for(ix=0; ix < 9; ix++)         ip[ix] = 42 ;      return 0; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 155k
  • Answers 155k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Perhaps this related question might help you. May 12, 2026 at 10:38 am
  • Editorial Team
    Editorial Team added an answer Use the setprecision() manipulator: http://www.cplusplus.com/reference/iostream/manipulators/setprecision/ You can also force scientific… May 12, 2026 at 10:38 am
  • Editorial Team
    Editorial Team added an answer The most obvious method of validating your XML would be:… May 12, 2026 at 10:38 am

Related Questions

Suppose I have some code that looks like this: foreach(type x in list y)
One of my projects on Linux uses blocking sockets. Things happen very serially so
I have code that looks like follows: public interface BaseDAO{ // marker interface }
I'm working on a problem in C# 2.0/.NET 2.0 where I have a Sortedlist

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.