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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:06:39+00:00 2026-06-15T22:06:39+00:00

I have a code, but have a warning when it was compiling, this was

  • 0

I have a code, but have a warning when it was compiling, this was the warning:

1_redis.c: In function \342\200\230main\342\200\231:
1_redis.c:131:23: warning: assignment makes integer from pointer without a cast
 [enabled by default]

it says assignment makes integer from pointer without a cast, but cFile and lQueryData are all char* type, why?

#define MAX_LINE_NUM 8000000
#define EACH_THREAD_NUM 10000


long i,posF,posDB;
for (i=0;i<DB_NUM;i++) { lQueryPerDB[i] = 0; }
char *lQueryData = (char *)malloc(DB_NUM*MAX_LINE_NUM*sizeof(char));

lLineCount = lFileLen / lLineLen;
for (i=0;i<lLineCount;i++) {
    posF = i * lLineLen;
    iDB = get_DB(cFile[posF]);
    posDB = iDB * MAX_LINE_NUM + lQueryPerDB[iDB];
    lQueryData[posDB] = &cFile[posF];                   // this line have warning!!!!
    lQueryPerDB[iDB]++;
}
  • 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-15T22:06:40+00:00Added an answer on June 15, 2026 at 10:06 pm

    If cFile is a char *, indexing it like cFile[posF] is the same as doing *(cFile + posF), or “give me the value of whatever is posF places from the start of the array.” Your address-of operator (&) is unnecessary, and if it weren’t, it would probably be the opposite of what you wanted (you want dereference — * — which is automatically done for you with the subscript notation).

    As other people have suggested, the correct code is most likely:

    lQueryData[posDB] = cFile[posF];
    

    The reason you get the particular warning you do is because using &cFile[posF] gets the address of (i.e., a pointer to) the character in cFile at posF. However, when you then try to assign it to a place in the lQueryData array, it has to first cast that (internally) into a scalar type. A pointer is just a number that indexes into memory, and thus when used for anything but “pointing” to things, it’s just an integer. Therefore, what you have is making an integer, from a pointer, without an explicit cast.

    You might consider compiling with clang instead of (what I presume is) GCC if you have access to it, it has much more accessible error messages. For instance, the error message for your code above is: warning: incompatible pointer to integer conversion assigning to ‘char’ with an expression of type ‘char *’; remove & (with a little visual pointer to the offending “&” sign).

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

Sidebar

Related Questions

Hey I have this code but it doesn't work because it is expecting a
I have write this code but it does work only if I am already
I have this line of code but it throws an error. What is the
I have this code that runs but never stops. class A { public static
I have this vb.net code ( but I think meaning code is equivalent for
I have code that looks more or less like the code below but it
I have the following code but it doesnt seem to work: <td align=center style=padding-bottom:52.5px>
I have the following code but the lon/lat seems to be returning null; package
I have the following code but I am unsure how I would adjust it
I have tried the following code but has no effect: Imports system.Runtime.InteropServices <DllImport(UxTheme.DLL, BestFitMapping:=False,

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.