C语言assignment makes pointer from integer without a cast

assignment to int from int makes pointer from integer without a cast wint conversion

这个警告的意思是将一个int整数值直接赋值给了一个指针变量。( 重点是类型不一致 )

消除警告的方法就是明确类型转换是否是正确的,如果确实要把整数变量赋予指针变量,那么请使用强制类型转换。否则,请用相同的数据类型,这样编译器就不会显示警告。

比如: int *p = 10;   //这就会产生这个警告

                                //因为 p 是指针变量,存放的是地址。而10是一个整数常量

改成: int *p = (int *)10    //强制转换成同一类型就可以消除警告

                                        //强制类型转换,10强制转换成了一个地址

assignment to int from int makes pointer from integer without a cast wint conversion

请填写红包祝福语或标题

assignment to int from int makes pointer from integer without a cast wint conversion

你的鼓励将是我创作的最大动力

assignment to int from int makes pointer from integer without a cast wint conversion

您的余额不足,请更换扫码支付或 充值

assignment to int from int makes pointer from integer without a cast wint conversion

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。 2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

assignment to int from int makes pointer from integer without a cast wint conversion

How to Fix Initialization Makes Pointer from Integer Without a Cast Error

David Henegar

If you are a developer, you might have come across the error message "initialization makes pointer from integer without a cast" during your programming career. This error message typically occurs when you try to assign an integer value to a pointer variable without explicitly casting the integer to a pointer. In this guide, we will discuss the causes of this error and provide you with a step-by-step solution to fix it.

Understanding the 'Initialization Makes Pointer from Integer Without a Cast' Error

Before we dive into the solution, let's first understand what this error message means. In C and C++, pointers are variables that hold memory addresses. They are used to access memory locations and manipulate data stored in those locations. When you assign an integer value to a pointer variable, the compiler treats it as an attempt to create a pointer from an integer, which is not allowed in C and C++. This is because pointers and integers have different data types and sizes.

The error message "initialization makes pointer from integer without a cast" is a compiler error that occurs when you try to assign an integer value to a pointer variable without explicitly casting the integer to a pointer type. This error message is typically accompanied by a line number and a file name that indicates where the error occurred.

Causes of the 'Initialization Makes Pointer from Integer Without a Cast' Error

The 'Initialization Makes Pointer from Integer Without a Cast' error can occur due to various reasons. Some of the common causes are:

  • Assigning an integer value to a pointer variable without casting it to a pointer type.
  • Using an incorrect data type for the pointer variable.
  • Declaring a pointer variable without initializing it.
  • Passing an integer value to a function that expects a pointer.

Solution to the 'Initialization Makes Pointer from Integer Without a Cast' Error

To fix the 'Initialization Makes Pointer from Integer Without a Cast' error, you need to cast the integer value to a pointer type before assigning it to a pointer variable. Here are the steps to fix this error:

  • Identify the line of code that is causing the error. The error message typically indicates the line number and the file name where the error occurred.
  • Check if the variable on the left-hand side of the assignment operator is a pointer variable. If it is not a pointer variable, you need to declare it as a pointer variable.
  • Cast the integer value to a pointer type using the appropriate casting operator. The casting operator in C and C++ is the (type) operator. For example, if you want to cast an integer value to a pointer to an integer, you can use the following syntax:
  • Compile and run your code to verify that the error has been fixed.

Frequently Asked Questions (FAQ)

Q1. what is a pointer in c and c++.

A pointer is a variable that holds the memory address of another variable. Pointers are used to access memory locations and manipulate data stored in those locations.

Q2. What is the data type of a pointer in C and C++?

The data type of a pointer depends on the data type of the variable it points to. For example, a pointer that points to an integer variable has the data type 'int *'.

Q3. What is a casting operator in C and C++?

A casting operator is an operator that is used to convert one data type to another. In C and C++, the casting operator is the (type) operator.

Q4. How do I declare a pointer variable in C and C++?

To declare a pointer variable in C and C++, you need to use the '*' operator. For example, to declare a pointer to an integer variable, you can use the following syntax:

Q5. Can I assign a pointer to an integer variable?

No, you cannot assign a pointer to an integer variable without casting it to an integer type. This is because pointers and integers have different data types and sizes.

Related Links

  • Casting Operators in C and C++
  • Pointers in C and C++

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Lxadm.com.

Your link has expired.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.

Position Is Everything

Makes Pointer From Integer Without a Cast: Fix It Now!

  • Recent Posts

Melvin Nolan

  • MySQL No Database Selected: Actionable Tips to Fix the Error - July 12, 2024
  • How to Un-Snooze Email in Outlook: A Step-by-Step Guide - July 12, 2024
  • How to Search Outlook for Multiple Words: Boost Your Efficiency - July 12, 2024

Makes Pointer From Integer Without a Cast

Our research team has ensured that this will be your best resource on these error messages, and you won’t have to read another article about it again. With that said, launch your code that’s showing the error messages, and let’s fix it for you.

JUMP TO TOPIC

– You Assigned an Integer to a Pointer

– you want to convert an integer to a pointer, – you passed a variable name to the “printf()” function, – you used “struct _io_file” in a wrong way, – you copied a string to an invalid location, – you’re setting a pointer to a different type, – use equal data types during assignment, – ensure the pointer and integer have the same sizes, – pass a “format string” to the “printf()” function, – use a function that returns a pointer to “struct _io_file”, – copy the string to character array or character pointer, – assign pointers of compatible types, why your code made a pointer from an integer without a cast.

Your code made a pointer from an integer without a cast because you assigned an integer to a pointer or you want to convert an integer to a pointer. Other causes include the passing of a variable name to the “printf()” function and using “struct _io_file in the wrong way.

Finally, the following are also possible causes:

  • You copied a string to an invalid location
  • You’re setting a pointer to a different type

If you assign an integer to a pointer, it will lead to the “ assignment makes pointer from integer without a cast c programming ” error. For example, in the following, the “num_array” variable is an unsigned integer type while “tmp_array” is a pointer.

Later, an error will occur when the “for” loop tries to copy the values of the “num_array” to the “tmp_array” pointer using a variable assignment.

#include<stdio.h>

#include<stdint.h>

uint8_t num_array[8] = {0, 1, 2, 3, 4, 5, 6, 7};

void copy_arr_values() {

int i;

uint8_t *tmp_array[8];

for(i=0; i<8; i++){

tmp_array[i] = num_array[(i+3)%8];

}

}

int main() {

copy_arr_values();

}

 

Makes Pointer From Integer Without a Cast Causes

For example, in the following, the “theta” variable is an integer while “ptr_theta” is a pointer. Both have different sizes, and you can’t convert the integer to a pointer.

#include<stdio.h>

int main() {

int theta = 10;

int *ptr_theta = (int *)theta;

}

If you pass a variable name to the “printf()” function, that’s when the compiler will throw the “ passing argument 1 of ‘printf’ makes pointer from integer without a cast ” error.

For example, in the following, “num_val” is an integer variable, and the code is trying to print it using the “printf()” function.

#include <stdio.h>

int main() {

int num_val = 42;

printf(num_val); //Error!

return 0;

}

When you assign an integer to a pointer of “struct _io_file”, that’s when you’ll get the “ assignment to file aka struct _io_file from int makes pointer from integer without a cast ” error. For example, in the following code, “FILE” is a “typedef” for “struct _io_file”. This makes it a pointer to “struct _io_file”.

Later, the code assigned it to the integer “alpha,” and this will lead to an error stated below:

#include <stdio.h>

int main(void) {

int alpha = 10;

FILE *beta = alpha;

return 0;

}

Makes Pointer From Integer Without a Cast Reasons

Now, in the following, the code is trying to copy a string (“source”) into an integer (“destination”), and this leads to an error because it’s not a valid operation:

#include<stdio.h>

#include<string.h>

int main() {

int destination;

char source[] = “Hello, World!”;

strcpy(destination, source);

return 0;

}

When your code sets a pointer to a different type, your compiler will show the “ incompatible pointer type ” error. In the following code, “pacifier” is an integer pointer, while “qwerty” is a character pointer.

Both are incompatible, and your C compiler will not allow this or anything similar in your code.

#include<stdio.h>

int main() {

int charlie = 5;

int *pacifier = &charlie;

char *qwerty = pacifier;

}

How To Stop a Pointer Creation From an Integer Without a Cast

You can stop a pointer creation from an integer without a cast if you use equal data types during the assignment or ensure the integer and pointer have the same sizes. What’s more, you can pass a “format string” to “printf()” and use a function that returns a pointer to “struct _io_file”.

  • Copy the string to a character array or character pointer
  • Assign pointers of compatible types

During a variable assignment, use variables of equal data types. In our first example, we assigned a pointer (uint8_t *tmp_array) to an unsigned integer (uint8_t num_array) and it led to a compile-time error.

Now, the following is the revised code, and we’ve changed “tmp_array” to a real array. This will prevent the “ gcc warning: assignment makes pointer from integer without a cast ” error during compilation.

#include<stdio.h>

#include<stdint.h>

uint8_t num_array[8] = {0, 1, 2, 3, 4, 5, 6, 7};

int main() {

int i;

// Fix: change tmp_array to an array

uint8_t tmp_array[8] = {};

for (i = 0; i < 8; i++){

tmp_array[i] = num_array[(i+3)%8];

}

int length = sizeof(tmp_array)/sizeof(tmp_array[0]);

printf(“Elements of the ‘tmp_array’: \n”);

for (int i = 0; i < length; i++) {

printf(“%d “, tmp_array[i]);

}

}

Makes Pointer From Integer Without a Cast Fixes

Now, the fix is to use “intptr_t” from the “stdint.h” header file because it guarantees that the pointer and integer will have the same sizes. We’ve used it in the following code, and you can compile it without an error.

#include<stdio.h>

#include<stdint.h>

int main() {

int theta = 10;

int *ptr_theta = (int *)(intptr_t)theta;

printf(“%p”, ptr_theta);

}

To fix the “pointer to integer without a cast” in the “printf()” function, pass a “format string” as its first argument. How you write the “format string” depends on the variable that you’ll print. In the following updated code, “num_val” is an integer, so the “format string” is “%d”.

#include <stdio.h>

int main() {

int num_val = 42;

printf(“%d”, num_val);

return 0;

}

When you’re using “FILE” from the “stdlib.h” header file, you can prevent any “pointer from integer” error if you use a function that returns a pointer to “struct _io_file”.

An example of such a function is “fopen()” which allows you to open a file in C programming. Now, the following is a rewrite of the code that causes the pointer error in “struct _io_file”. This time, we use “fopen()” as a pointer to “FILE”.

#include <stdio.h>

int main(void) {

FILE *f = fopen(“myfile.txt”, “r”);

if (f == NULL) {

perror(“Error opening file”);

return 1;

}

char c;

while ((c = fgetc(f)) != EOF) {

printf(“%c”, c);

}

return 0;

}

Makes Pointer From Integer Without a Cast Solutions

Now, in the following code, we’ve changed “destination” from an integer to a “character array”. This means “strcpy()” can copy a string into this array without an error.

#include<stdio.h>

#include<string.h>

int main() {

char destination[100];

char source[] = “Hello, World!”;

strcpy(destination, source);

printf(“%s”, destination);

return 0;

}

Meanwhile, the following is another version that turns the “destination” into a “character pointer”. With this, you’ll need to allocate memory using the “malloc()” function from the “stdlib.h” header file.

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

int main() {

char* destination;

char source[] = “Hello, World!”;

destination = malloc(100);

strcpy(destination, source);

printf(“%s”, destination);

free(destination);

return 0;

}

When you’re assigning pointers, ensure that they’re compatible by changing their data type . The following is the updated code for the “charlie” example , and “qwerty” is now an integer.

#include<stdio.h>

int main() {

int charlie = 5;

int *pacifier = &charlie;

int *qwerty = pacifier;

}

This article explained why your code made a pointer without a cast and how you can fix it. The following is a summary of what we talked about:

  • An attempt to convert an integer to a pointer will lead to the “makes pointer from integer without a cast wint conversion” error.
  • To prevent an “incompatible pointer type” error, don’t set a pointer to a different type.
  • If you’re using the “printf()” function, and you want to prevent any “pointer to integer” error, always pass a “format specifier”.

At this stage, you’ll be confident that you can work with integers and pointers in C programming without an error. Save our article, and share it with your developer communities to help them get rid of this error as well.

Related posts:

  • Input String Was Not in a Correct Format: Working Solutions
  • Best solutions to get rid of “operand should contain 1 column(s)” error
  • Another Git Process Seems To Be Running in This Repository: Solutions
  • Linker Command Failed With Exit Code 1: Causes and Fixes of This Error
  • Valueerror: No Json Object Could Be Decoded: Fix This Python Error
  • Conversion Failed When Converting Date And/or Time From Character String.
  • Importerror: Libcublas.So.9.0: Cannot Open Shared Object File: No Such File or Directory
  • Exception Code 0xe0434352: Read or Let It Disturb You
  • Noclassdeffounderror: An Article That Explains the Details
  • HTTP Error 500.19 – Internal Server Error: Fixing the Issue
  • Libressl SSL_connect: SSL_error_syscall in Connection to Github.com:443
  • Kudu Giving Forbidden Error 403: The Necessary Guide

Leave a Comment Cancel reply

Save my name, email, and website in this browser for the next time I comment.

  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Assignment makes integer from pointer without a cast [-Wint-conversion

I really don't understand why I have such error knowing that tmp and key are the same type and size.

This produces:

warning: assignment makes integer from pointer without a cast [-Wint-conversion
  • variable-assignment

Sourav Ghosh's user avatar

2 Answers 2

tmp and key are the same type

NO . They are not. They both are arrays, but the datatype is different. One is a uint8_t * array, another is a uint8_t array.

  • 1 It wasn't my downvote, but I don't see where his code uses a pointer from tmp uninitialized. He's assigning to the i th item of tmp , not dereferencing it. It's hardly undefined behavior to assign to an uninitialized pointer. –  Cody Gray ♦ Commented Jan 18, 2016 at 5:16
  • @CodyGray You're right sir, I also got confused by the data types....Thanks for pointing that out. But then, regarding the DV, it was before I added that part, as an edit.....so, .... :( –  Sourav Ghosh Commented Jan 18, 2016 at 7:51

Not clear what you want here but if you want tmp[x] to reflect the value in key[y] then

Otherwise if you want tmp to be separate, then ...

mksteve's user avatar

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged c arrays pointers variable-assignment uint8t or ask your own question .

  • The Overflow Blog
  • The hidden cost of speed
  • The creator of Jenkins discusses CI/CD and balancing business with open source
  • Featured on Meta
  • Announcing a change to the data-dump process
  • Bringing clarity to status tag usage on meta sites
  • What does a new user need in a homepage experience on Stack Overflow?
  • Feedback requested: How do you use tag hover descriptions for curating and do...
  • Staging Ground Reviewer Motivation

Hot Network Questions

  • PCA to help select variables?
  • Are incomplete magic squares with some integral entries necessarily purely integral
  • What would be a good weapon to use with size changing spell
  • Is the 2024 Ukrainian invasion of the Kursk region the first time since WW2 Russia was invaded?
  • Is there a way to read lawyers arguments in various trials?
  • Remove an edge from the Hasse diagram of a finite lattice
  • Sum[] function not computing the sum
  • Manhattan distance
  • Breaker trips when plugging into wall outlet(receptacle) directly, but not when using extension
  • Fusion September 2024: Where are we with respect to "engineering break even"?
  • What are the most commonly used markdown tags when doing online role playing chats?
  • What is the first work of fiction to feature a vampire-human hybrid or dhampir vampire hunter as a protagonist?
  • In which town of Europe (Germany ?) were this 2 photos taken during WWII?
  • Is "She played good" a grammatically correct sentence?
  • Nausea during high altitude cycling climbs
  • do-release-upgrade from 22.04 LTS to 24.04 LTS still no update available
  • What`s this? (Found among circulating tumor cells)
  • Questions about LWE in NIST standards
  • Why is this bolt's thread the way it is?
  • Is there a problem known to have no fastest algorithm, up to polynomials?
  • Is there a non-semistable simple sheaf?
  • Gravitational potential energy of a water column
  • Is there a way to prove ownership of church land?
  • Draw a topological puzzle using tikz

assignment to int from int makes pointer from integer without a cast wint conversion

Nordic DevZone

  • Online Power Profiler
  •  > 
  • Nordic Q&A
  • State Verified Answer
  • Replies 7 replies
  • Subscribers 66 subscribers
  • Views 6574 views
  • Users 0 members are here
  • development
  • Case ID: 254703

compiler warning: pointer from integer without a cast

Would appreciate some understanding of a compiler warning. Developing for nRF52832 using SDK 15.3.0 plus S112.

This code compiles without warning:

ret_code_t err_code; err_code = nrfx_ppi_channel_assign(chan_0, nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN),nrfx_timer_task_address_get(&m_timer1,NRF_TIMER_TASK_START)); APP_ERROR_CHECK(err_code);

Then I switch from nrfx to sd calls:

ret_code_t err_code; err_code = sd_ppi_channel_assign(chan_0, nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN),nrfx_timer_task_address_get(&m_timer1,NRF_TIMER_TASK_START)); APP_ERROR_CHECK(err_code);

and the following warnings:

passing argument 2 of 'sd_ppi_channel_assign' makes pointer from integer without a cast [-Wint-conversion]

passing argument 3 of 'sd_ppi_channel_assign' makes pointer from integer without a cast [-Wint-conversion]

All seems to work, but would appreciate understanding the warnings.

Many thanks,

  • Sign in to reply

Top Replies

tesc

Take a look at the API documentation for explanation:

nrfx_ppi_channel_assign

sd_ppi_channel_assign

The second one takes a pointer to a variable, while the first one takes a value. I would have call nrfx_gpiote_in_event_addr_get and nrfx_timer_task_address_get first and saved the results in their own variables that you can then pass via a pointer (&) to the sd_ppi_channel_assign. It's a bit surprising that you were able to compile with the wrong argument type. Pointers are the numbers containing the memory address of a variable instead of being the variable themselves. Therefore it could technically work, but would be very likely to behave incorrectly or even crash due to wrong values. That's what the compiler is warning you about.

Best regards,

  • Vote Up 0 Vote Down
  • Verify Answer

Thank you Marjeris. Makes sense. I incorrectly assumed the function parameters were the same.

However, it's odd that it worked. Compiler warnings went away, but PPI stopped working when I changed the code to:

ret_code_t err_code; uint32_t event_addr = nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN); uint32_t task_addr = nrfx_timer_task_address_get(&m_timer1,NRF_TIMER_TASK_START); err_code = sd_ppi_channel_assign(chan_0, &event_addr, &task_addr); APP_ERROR_CHECK(err_code);

I need to debug and see if sd_ppi_channel_assign returns an error. Will do so, but thought to check if the above code looks correct to you.

Also, when I search devzone, all posts with sd_ppi_channel_assign access peripherals (TIMER, GPIOTE, etc.) directly, except for this post , which casts nrf_drv_gpiote_in_event_addr_get and nrf_drv_timer_task_address_get to (const volatile void *). This resolves the compiler warnings, but would like to confirm this is correct code.

Jørgen Holmefjord

The correct approach is to cast the type  (const volatile void *) when providing the variables (or events/task addresses). The  sd_ppi_channel_assign () function is taking pointers, but the event/task addresses can be seen as pointers itself. It is therefore not correct to pass a pointer to the variables, as this will lead to PPI endpoints being set to addresses in RAM, which are not supported.

ret_code_t err_code; uint32_t event_addr = nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN); uint32_t task_addr = nrfx_timer_task_address_get(&m_timer1,NRF_TIMER_TASK_START); err_code = sd_ppi_channel_assign(chan_0, (const volatile void *)event_addr, (const volatile void *)task_addr); APP_ERROR_CHECK(err_code);

Best regards, Jørgen

Thank you Jørgen. I think I understand.

Am I correct to say that this:

is equivalent to:

ret_code_t err_code; err_code = sd_ppi_channel_assign(chan_0, (const volatile void *)nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN), (const volatile void *)nrfx_timer_task_address_get(&m_timer1,NRF_TIMER_TASK_START));

Any advantages of one compared to the other?

Get the Reddit app

The subreddit for the C programming language

assignment makes integer from pointer without a cast

I'm trying to parse network packets in C as:

ip_hdr_t is a struct defines the IP header and it has a member uint8_t ihl:4 .

When compiling the code it gave warnings and errors:

I understand the first warning, but how did the second one in line 60 come? ip_hdr is uint8_t* and ip_hdr_len is uint8_t , so I expect the addition produces an uint8_t* instead of an integer ?

By continuing, you agree to our User Agreement and acknowledge that you understand the Privacy Policy .

Enter the 6-digit code from your authenticator app

You’ve set up two-factor authentication for this account.

Enter a 6-digit backup code

Create your username and password.

Reddit is anonymous, so your username is what you’ll go by here. Choose wisely—because once you get a name, you can’t change it.

Reset your password

Enter your email address or username and we’ll send you a link to reset your password

Check your inbox

An email with a link to reset your password was sent to the email address associated with your account

Choose a Reddit account to continue

COMMENTS

  1. Assignment makes pointer from integer without cast

    However, this returns a char. So your assignment. cString1 = strToLower(cString1); has different types on each side of the assignment operator .. you're actually assigning a 'char' (sort of integer) to an array, which resolves to a simple pointer. Due to C++'s implicit conversion rules this works, but the result is rubbish and further access to ...

  2. C pointers and arrays: [Warning] assignment makes pointer from integer

    In this case a[4] is the 5th integer in the array a, ap is a pointer to integer, so you are assigning an integer to a pointer and that's the warning. So ap now holds 45 and when you try to de-reference it (by doing *ap) you are trying to access a memory at address 45, which is an invalid address, so your program crashes.. You should do ap = &(a[4]); or ap = a + 4;

  3. C语言assignment makes pointer from integer without a cast

    C语言assignment makes pointer from integer without a cast. 这个警告的意思是将一个int整数值直接赋值给了一个指针变量。. (重点是类型不一致). 消除警告的方法就是明确类型转换是否是正确的,如果确实要把整数变量赋予指针变量,那么请使用 强制类型转换。. 否则 ...

  4. Makes Integer From Pointer Without A Cast (Resolved)

    Converting Integers to Pointers {#converting-integers-to-pointers} To convert an integer to a pointer, follow these steps: Include the <stdint.h> header (C) or the <cstdint> header (C++) in your program. Cast your integer to the required pointer type using a double cast. int a = 42; uintptr_t int_ptr = (uintptr_t)&a;

  5. Assignment makes integer from pointer without a cast in c

    We are trying here to assign the return of getinteger function which is a pointer that conatains a memory address to the result variable that is an int type which needs an integer Case 3: Misusing ...

  6. Assignment makes integer from pointer without a cast and ...

    OK - in that case, since you want to immediately change the value of sad, it can be a local variable to the function, and doesn't need to be an argument to the function: . void racun(int D, int M, int G, int *dUg) { int i, *sad; If you want sad to point to an array, such that accessing sad (sad[...]) will be equivalent to accessing that array (e.g. obicna[...]), you can simply assign the array ...

  7. Initialization Makes Pointer From Integer Without A Cast (Resolved)

    To fix the 'Initialization Makes Pointer from Integer Without a Cast' error, you need to cast the integer value to a pointer type before assigning it to a pointer variable. Here are the steps to fix this error:

  8. c

    1. Earlier, I asked a similar question, but I've since changed my code. Now the compiler gives me a different warning. This is an example of what my code looks like now: void *a = NULL; void *b = //something; a = *(int *)((char *)b + 4); When I try to compile, I get "warning: assignment makes pointer from integer without a cast."

  9. "assignment makes integer from pointer without a cast -wint-conversion

    "assignment makes integer from pointer without a cast -wint ...

  10. Need help with C, keep getting "assignment makes pointer from integer

    char *word is a pointer, meaning the value contained by the word parameter is a memory address (in this example, it will be the address of the first character in a string). When you use the notation *word on line 19, you are dereferencing the word pointer, meaning it will return the value of whatever is stored at word's memory address (which is a single character).

  11. Makes Pointer From Integer Without a Cast: Fix It Now!

    How To Stop a Pointer Creation From an Integer Without a Cast. - Use Equal Data Types During Assignment. - Ensure the Pointer and Integer Have the Same Sizes. - Pass a "Format String" to the "Printf ()" Function. - Use a Function That Returns a Pointer to "Struct _IO_file". - Copy the String to Character Array or Character ...

  12. [C] Cannot get rid of a [-Wint-conversion] warning

    initialization makes pointer from integer without a cast You are initializing your reversed_arr variable, which is a pointer to a char, with the result of the reverse function, which returns a char (which is basically an integer), which is why you are getting your warning. You could try: char *reversed_arr = (char *) reverse(arr);

  13. Assignment makes integer from pointer without a cast [-Wint-conversion

    It wasn't my downvote, but I don't see where his code uses a pointer from tmp uninitialized. He's assigning to the i th item of tmp , not dereferencing it. It's hardly undefined behavior to assign to an uninitialized pointer.

  14. assignment makes integer from pointer without a cast

    text should be declared as: char *text = NULL; You need a pointer to char. This pointer can be set to point to any literal string (as you do in your case statements). char text; // this is just a single character (letter), not a string. 2. Objective_Ad_4587 • 3 yr. ago. i got it thank you very much.

  15. compiler warning: pointer from integer without a cast

    passing argument 3 of 'sd_ppi_channel_assign' makes pointer from integer without a cast [-Wint-conversion] All seems to work, but would appreciate understanding the warnings. Many thanks, Tim. Hi, From what I can tell, the two are equivalent (except for the second one missing the call to APP_ERROR_CHECK ()).

  16. How to fix "warning: assignment to 'int (*)(int, int, int, void

    How to fix "warning: assignment to 'int (*)(int, int, int, void *)' from 'int' makes pointer from integer without a cast [-Wint-conversion]" I am currently reading a book on Ethical Hacking and I have hit a road block with this warning. The book uses C for this example in Sys call hooking, and I seem to keep getting this warning message ...

  17. assignment makes integer from pointer without a cast

    When compiling the code it gave warnings and errors: network.c:51:12: warning: assignment discards 'const' qualifier from pointer target type [enabled by default] network.c:60:12: warning: assignment makes integer from pointer without a cast [enabled by default] network.c:64:26: error: invalid type argument of unary '*' (have 'int ...