Solving Assignment Makes Integer from Pointer Without a Cast in C: Tips and Solutions

David Henegar

As a developer, encountering errors while coding is inevitable. One common error that C programmers come across is the "assignment makes integer from pointer without a cast" error. This error message can be frustrating and time-consuming to resolve, but with the right tips and solutions, it can be easily fixed.

Understanding the Error Message

Before we dive into the tips and solutions for fixing this error, let's first understand what it means. The "assignment makes integer from pointer without a cast" error occurs when a pointer is assigned to an integer without a proper type cast. This error message is often accompanied by a warning message that looks like this:

This warning message is telling the programmer that the code is trying to assign a pointer value to an integer variable without casting the pointer to the correct type.

Tips for Fixing the Error

Here are some tips to help you fix the "assignment makes integer from pointer without a cast" error:

Tip #1: Check Your Pointer Types

Make sure that the pointer you are trying to assign to an integer variable is of the correct data type. If the pointer is pointing to a different data type, you will need to cast it to the correct type before assigning it to the integer variable.

Tip #2: Use the Correct Syntax

When casting a pointer to a different data type, make sure to use the correct syntax. The syntax for casting a pointer to an integer is (int) pointer .

Tip #3: Use the Correct Assignment Operator

Make sure that you are using the correct assignment operator. The assignment operator for pointers is = while the assignment operator for integers is == .

Tip #4: Check Your Code for Errors

Double-check your code for errors. Sometimes, the "assignment makes integer from pointer without a cast" error can be caused by a syntax error or a missing semicolon.

Solutions for Fixing the Error

Now that you have some tips for fixing the "assignment makes integer from pointer without a cast" error, let's look at some solutions.

Solution #1: Cast the Pointer to the Correct Type

To fix this error, you need to cast the pointer to the correct type before assigning it to the integer variable. Here's an example:

In this example, the pointer is cast to an integer using the (int) syntax before it is assigned to the num variable.

Solution #2: Declare the Integer Variable as a Pointer

Another solution is to declare the integer variable as a pointer. Here's an example:

In this example, the num variable is declared as a pointer, and the ptr variable is assigned to it without casting.

Q1: What causes the "assignment makes integer from pointer without a cast" error?

A: This error occurs when a pointer is assigned to an integer variable without being cast to the correct data type.

Q2: How do I cast a pointer to an integer in C?

A: To cast a pointer to an integer in C, use the (int) syntax.

Q3: Why is my code still giving me the same error message even after I cast the pointer to the correct type?

A: Double-check your code for syntax errors and missing semicolons. Sometimes, these errors can cause the same error message to appear even after you have cast the pointer to the correct type.

Q4: Can I declare the integer variable as a pointer to fix this error?

A: Yes, you can declare the integer variable as a pointer to fix this error.

Q5: What is the correct assignment operator for pointers and integers in C?

A: The assignment operator for pointers is = while the assignment operator for integers is == .

The "assignment makes integer from pointer without a cast" error can be frustrating, but with the right tips and solutions, it can be easily fixed. By understanding the error message and following the tips and solutions provided in this guide, you can resolve this error and improve the functionality of your code.

Related Links

assignment to char from void makes integer from pointer without a cast wint conversion

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.

  • GitHub Login
  • Twitter Login

Welcome to Coder Legion Community

With 325 amazing developers, connect with, already have an account log in.

  • Share on Facebook
  • Share on Twitter
  • Share on Reddit
  • Share on LinkedIn
  • Share on Pinterest
  • Share on HackerNews

Assignment makes integer from pointer without a cast in c

assignment to char from void makes integer from pointer without a cast wint conversion

Programming can be both rewarding and challenging. You work hard on your code, and just when it seems to be functioning perfectly, an error message pops up on your screen, leaving you frustrated and clueless about what went wrong. One common error that programmers encounter is the "Assignment makes integer from pointer without a cast" error in C.

This error occurs when you try to assign a value from a pointer variable to an integer variable without properly casting it. To fix this error, you need to make sure that you cast the pointer value to the appropriate data type before assigning it to an integer variable. In this article, we will dive deeper into the causes of this error and provide you with solutions to overcome it.

assignment to char from void makes integer from pointer without a cast wint conversion

What makes this error occur?

I will present some cases that triggers that error to occur, and they are all have the same concept, so if you understanded why the failure happens, then you will figure out how to solve all the cases easily.

Case 1: Assignment of a pointer to an integer variable

In this simple code we have three variables, an integer pointer "ptr" , and two integers "n1" and "n2" . We assign 2 to "n1" , so far so good, then we assign the address of "n2" to "ptr" which is the suitable storing data type for a pointer, so no problems untill now, till we get to this line "n2 = ptr" when we try to assign "ptr" which is a memory address to "n2" that needs to store an integer data type because it's not a pointer.

Case 2: Returning a Pointer from a Function that Should Return an Integer

As you can see, it's another situation but it's the same idea which causes the compilation error.  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 Array Names as Pointers

As we might already know, that the identifier (name) of the array is actually a pointer to the array first element memory address , so it's a pointer after all, and assigning a pointer type to int type causes the same compilation error.

The solutions

The key to avoiding the error is understanding that pointers and integers are different types of variables in C. Pointers hold memory addresses, while integers hold numeric values. We can use either casting , dereferencing the pointer or just redesign another solution for the problem we are working on that allows the two types to be the same. It all depending on the situation.

Let's try to solve the above cases:

Case 1: Solution: Deferencing the pointer

We need in this case to asssign an int type to "n2" not a pointer or memory address, so how do we get the value of the variable that the pointer "ptr" pointing to? We get it by deferencing the pointer , so the code after the fix will be like the following:

Case 2: Solution: Choosing the right data type

In this case we have two options, either we change the getinteger returning type to int or change the result variable type to a pointer . I will go with the latter option, because there are a lot of functions in the C standard library that returning a pointer, so what we can control is our variable that takes the function return. So the code after the fix will be like the following:

We here changed the result variable from normal int to an int pointer by adding "*" .

Case 3: Solution: Using the array subscript operator

In this case we can get the value of any number in the array  by using the subscript opeartor ([]) on the array with the index number like: myarray[1] for the second element which is 2 . If we still remember that the array identifier is a pointer to the array first memory, then we can also get the value of the array first element by deferencing the array identifier like: *myarray which will get us 1 .

But let's solve the case by using the subscript opeartor which is the more obvious way. So the code will be like the following:

Now the number 1 is assigned to myint without any compilation erros.

The conclusion

In conclusion, the error "assignment to ‘int’ from ‘int *’ makes integer from pointer without a cast" arises in C programming when there is an attempt to assign a memory address (held by a pointer) directly to an integer variable. This is a type mismatch as pointers and integers are fundamentally different types of variables in C.

To avoid or correct this error, programmers need to ensure they are handling pointers and integers appropriately. If the intent is to assign the value pointed by a pointer to an integer, dereferencing should be used. If a function is meant to return an integer, it should not return a pointer. When dealing with arrays, remember that the array name behaves like a pointer to the first element, not an individual element of the array.

Please log in to add a comment.

- Sep 8, 2023
- Jun 4
- Jun 1
- May 6
- Apr 9
  • Send feedback

More From Phantom

Tips and tricks in article formatting for coderlegion, markdown divs in coderlegion, code formatting tests in coderlegion.

Ubuntu Forums

  • Unanswered Posts
  • View Forum Leaders
  • Contact an Admin
  • Forum Council
  • Forum Governance
  • Forum Staff

Ubuntu Forums Code of Conduct

  • Forum IRC Channel
  • Get Kubuntu
  • Get Xubuntu
  • Get Lubuntu
  • Get Ubuntu Studio
  • Get Ubuntu Cinnamon
  • Get Edubuntu
  • Get Ubuntu Unity
  • Get Ubuntu Kylin
  • Get Ubuntu Budgie
  • Get Ubuntu Mate
  • Ubuntu Code of Conduct
  • Ubuntu Wiki
  • Community Wiki
  • Launchpad Answers
  • Ubuntu IRC Support
  • Official Documentation
  • User Documentation
  • Distrowatch
  • Bugs: Ubuntu
  • PPAs: Ubuntu
  • Web Upd8: Ubuntu
  • OMG! Ubuntu
  • Ubuntu Insights
  • Planet Ubuntu
  • Full Circle Magazine
  • Activity Page
  • Please read before SSO login
  • Advanced Search

Home

  • The Ubuntu Forum Community
  • Ubuntu Specialised Support
  • Development & Programming
  • Programming Talk

[SOLVED] C - assigment makes integer from pointer without a cast warning

  • Hello Unregistered, you are cordially invited to participate in a discussion about the future of the forum. Please see this thread .

Thread: [SOLVED] C - assigment makes integer from pointer without a cast warning

Thread tools.

  • Show Printable Version
  • Subscribe to this Thread…
  • Linear Mode
  • Switch to Hybrid Mode
  • Switch to Threaded Mode
  • View Profile
  • View Forum Posts
  • Private Message

usernamer is offline

I know it's a common error, and I've tried googling it, looked at a bunch of answers, but I still don't really get what to do in this situation.... Here's the relevant code: Code: #include <stdio.h> #include <stdlib.h> #include <string.h> int main( int argc, char *argv[] ) { char path[51]; const char* home = getenv( "HOME" ); strcpy( path, argv[1] ); path[1] = home; return 0; } -- there is more code in the blank lines, but the issue's not there (I'm fairly sure), so didn't see the point in writing out 100 odd lines of code. I've tried some stuff like trying to make a pointer to path[1], and make that = home, but haven't managed to make that work (although maybe that's just me doing it wrong as opposed to wrong idea?) Thanks in advance for any help

r-senior is offline

Re: C - assigment makes integer from pointer without a cast warning

path[1] is the second element of a char array, so it's a char. home is a char *, i.e. a pointer to a char. You get the warning because you try to assign a char* to a char. Note also the potential to overflow your buffer if the content of the argv[1] argument is very long. It's usually better to use strncpy.
Last edited by r-senior; March 10th, 2013 at 03:03 PM . Reason: argv[1] would overflow, not HOME. Corrected to avoid confusion.
Please create new threads for new questions. Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].
  • Visit Homepage

Christmas is offline

You can try something like this: Code: #include <stdio.h> #include <stdlib.h> #include <string.h> int main( int argc, char *argv[] ) { char *path; const char *home = getenv("HOME"); path = malloc(strlen(home) + 1); if (!path) { printf("Error\n"); return 0; } strcpy(path, home); printf("path = %s\n", path); // if you want to have argv[1] concatenated with path if (argc >= 2) { path = malloc(strlen(home) + strlen(argv[1]) + 1); strcpy(path, argv[1]); strcat(path, home); printf("%s\n", path); } // if you want an array of strings, each containing path, argv[1]... char **array; int i; array = malloc(argc * sizeof(char*)); array[0] = malloc(strlen(home) + 1); strcpy(array[0], home); printf("array[0] = %s\n", array[0]); for (i = 1; i < argc; i++) { array[i] = malloc(strlen(argv[i]) + 1); strcpy(array[i], argv[i]); printf("array[%d] = %s\n", i, array[i]); } // now array[i] will hold path and all the argv strings return 0; } Just as above, your path[51] is a string while path[1] is only a character, so you can't use strcpy for that.
Last edited by Christmas; March 10th, 2013 at 09:51 PM .
TuxArena - Ubuntu/Debian/Mint Tutorials | Linux Stuff Intro Tutorials | UbuTricks I play Wesnoth sometimes. And AssaultCube .
Originally Posted by Christmas You can try something like this: Code: #include <stdio.h> #include <stdlib.h> #include <string.h> int main( int argc, char *argv[] ) { char *path; const char *home = getenv("HOME"); path = malloc(strlen(home) + 1); if (!path) { printf("Error\n"); return 0; } strcpy(path, home); printf("path = %s\n", path); // if you want to have argv[1] concatenated with path if (argc >= 2) { path = malloc(strlen(home) + strlen(argv[1]) + 1); strcpy(path, argv[1]); strcat(path, home); printf("%s\n", path); } // if you want an array of strings, each containing path, argv[1]... char **array; int i; array = malloc(argc * sizeof(char*)); array[0] = malloc(strlen(home) + 1); strcpy(array[0], home); printf("array[0] = %s\n", array[0]); for (i = 1; i < argc; i++) { array[i] = malloc(strlen(argv[i]) + 1); strcpy(array[i], argv[i]); printf("array[%d] = %s\n", i, array[i]); } // now array[i] will hold path and all the argv strings return 0; } Just as above, your path[51] is a string while path[1] is only a character, so you can't use strcpy for that. Excellent point. I've basically fixed my problem by reading up on pointers again (haven't done any C for a little while, so forgot some stuff), and doing: Code: path[1] = *home; the code doesn't moan at me when I compile it, and it runs okay (for paths which aren't close to 51 at least), but after reading what you read, I just wrote a quick program and found out that getenv("HOME") is 10 characters long, not 1 like I seem to have assumed, so I'll modify my code to fix that.
Yes, getenv will return the path to your home dir, for example /home/user, but path[1] = *home will still assign the first character of home to path[1] (which would be '/').
  • Private Messages
  • Subscriptions
  • Who's Online
  • Search Forums
  • Forums Home
  • New to Ubuntu
  • General Help
  • Installation & Upgrades
  • Desktop Environments
  • Networking & Wireless
  • Multimedia Software
  • Ubuntu Development Version
  • Virtualisation
  • Server Platforms
  • Ubuntu Cloud and Juju
  • Packaging and Compiling Programs
  • Development CD/DVD Image Testing
  • Ubuntu Application Development
  • Ubuntu Dev Link Forum
  • Bug Reports / Support
  • System76 Support
  • Apple Hardware Users
  • Recurring Discussions
  • Mobile Technology Discussions (CLOSED)
  • Announcements & News
  • Weekly Newsletter
  • Membership Applications
  • The Fridge Discussions
  • Forum Council Agenda
  • Request a LoCo forum
  • Resolution Centre
  • Ubuntu/Debian BASED
  • Arch and derivatives
  • Fedora/RedHat and derivatives
  • Mandriva/Mageia
  • Slackware and derivatives
  • openSUSE and SUSE Linux Enterprise
  • Gentoo and derivatives
  • Any Other OS
  • Assistive Technology & Accessibility
  • Art & Design
  • Education & Science
  • Documentation and Community Wiki Discussions
  • Outdated Tutorials & Tips
  • Ubuntu Women
  • Arizona Team - US
  • Arkansas Team - US
  • Brazil Team
  • California Team - US
  • Canada Team
  • Centroamerica Team
  • Instalación y Actualización
  • Colombia Team - Colombia
  • Georgia Team - US
  • Illinois Team
  • Indiana - US
  • Kentucky Team - US
  • Maine Team - US
  • Minnesota Team - US
  • Mississippi Team - US
  • Nebraska Team - US
  • New Mexico Team - US
  • New York - US
  • North Carolina Team - US
  • Ohio Team - US
  • Oklahoma Team - US
  • Oregon Team - US
  • Pennsylvania Team - US
  • Texas Team - US
  • Uruguay Team
  • Utah Team - US
  • Virginia Team - US
  • West Virginia Team - US
  • Australia Team
  • Bangladesh Team
  • Hong Kong Team
  • Myanmar Team
  • Philippine Team
  • Singapore Team
  • Albania Team
  • Catalan Team
  • Portugal Team
  • Georgia Team
  • Ireland Team - Ireland
  • Kenyan Team - Kenya
  • Kurdish Team - Kurdistan
  • Lebanon Team
  • Morocco Team
  • Saudi Arabia Team
  • Tunisia Team
  • Other Forums & Teams
  • Afghanistan Team
  • Alabama Team - US
  • Alaska Team - US
  • Algerian Team
  • Andhra Pradesh Team - India
  • Austria Team
  • Bangalore Team
  • Bolivia Team
  • Cameroon Team
  • Colorado Team - US
  • Connecticut Team
  • Costa Rica Team
  • Ecuador Team
  • El Salvador Team
  • Florida Team - US
  • Galician LoCo Team
  • Hawaii Team - US
  • Honduras Team
  • Idaho Team - US
  • Iowa Team - US
  • Jordan Team
  • Kansas Team - US
  • Louisiana Team - US
  • Maryland Team - US
  • Massachusetts Team
  • Michigan Team - US
  • Missouri Team - US
  • Montana Team - US
  • Namibia Team
  • Nevada Team - US
  • New Hampshire Team - US
  • New Jersey Team - US
  • Northeastern Team - US
  • Panama Team
  • Paraguay Team
  • Quebec Team
  • Rhode Island Team - US
  • Senegal Team
  • South Carolina Team - US
  • South Dakota Team - US
  • Switzerland Team
  • Tamil Team - India
  • Tennessee Team - US
  • Trinidad & Tobago Team
  • Uganda Team
  • United Kingdom Team
  • US LoCo Teams
  • Venezuela Team
  • Washington DC Team - US
  • Washington State Team - US
  • Wisconsin Team
  • Za Team - South Africa
  • Zimbabwe Team

Tags for this Thread

View Tag Cloud

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  • BB code is On
  • Smilies are On
  • [IMG] code is On
  • [VIDEO] code is Off
  • HTML code is Off
  • Ubuntu Forums

C Board

  • Today's Posts
  • C and C++ FAQ
  • Mark Forums Read
  • View Forum Leaders
  • What's New?
  • Get Started with C or C++
  • C++ Tutorial
  • Get the C++ Book
  • All Tutorials
  • Advanced Search

Home

  • General Programming Boards
  • C Programming

Assignment makes pointer from integer without a cast

  • Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems

Thread: Assignment makes pointer from integer without a cast

Thread tools.

  • Show Printable Version
  • Email this Page…
  • Subscribe to this Thread…

Search Thread

  •   Advanced Search
  • Linear Mode
  • Switch to Hybrid Mode
  • Switch to Threaded Mode
  • View Profile
  • View Forum Posts

deciel is offline

I keep getting this error message: "warning: assignment makes pointer from integer without a cast" for line 17 (which I've made red). I've gotten this message a few times before, but I can't remember how I fixed it, and I can't figure out how to fix this one. Any suggestions? Also, it's a code that will take a password entered by the user and then run several for loops until it matches the password. It prints what it's figured out each time it guesses a new letter. Code: #include <stdio.h> #include <string.h> int main(void) { int i, j; char password[25]; char cracked[25]; char *p; char guess = '!'; printf("Enter a password of 25 characters or less: \n"); scanf("%s", password); printf("Password is being cracked..."); for (i = 0, p = password[i]; i < 25; i++, p++) { for(j = 0; j < 90; j++) { if (*p == guess) { strcpy(p, cracked); printf("\t %s \n"); break; } guess++; } //end <search> for loop } //end original for loop return 0; }
Last edited by deciel; 12-13-2011 at 01:57 AM .

JohnGraham is offline

Code: for (i = 0, p = password[i]; i < 25; i++, p++) password[i] is the value at index i of password . You want the address of said value, so you want p = &password[i] (or, equivalently, p = password + i ).
Oh! Thank you, it worked!

sparkomemphis is offline

Originally Posted by deciel I keep getting this error message: "warning: for (i = 0, p = password[i]; i < 25; i++, p++) [/CODE] Note: password[i] == password[0] == *password since this is the assignment portion of for loop and i is set to zero (0).

Tclausex is offline

If you want to set a pointer to the beginning of an array, just use Code: p = password An array name is essentially a pointer to the start of the array memory. Note, for a null terminated string, you could just test for Code: *p //or more explicitly *p == '\0' Also, a 25-element char array doesn't have room for a 25 character string AND a null terminator. And, ask yourself, what's going on when I enter, say a 10 character password, and i > 10.
  • Private Messages
  • Subscriptions
  • Who's Online
  • Search Forums
  • Forums Home
  • C++ Programming
  • C# Programming
  • Game Programming
  • Networking/Device Communication
  • Programming Book and Product Reviews
  • Windows Programming
  • Linux Programming
  • General AI Programming
  • Article Discussions
  • General Discussions
  • A Brief History of Cprogramming.com
  • Contests Board
  • Projects and Job Recruitment

subscribe to a feed

  • How to create a shared library on Linux with GCC - December 30, 2011
  • Enum classes and nullptr in C++11 - November 27, 2011
  • Learn about The Hash Table - November 20, 2011
  • Rvalue References and Move Semantics in C++11 - November 13, 2011
  • C and C++ for Java Programmers - November 5, 2011
  • A Gentle Introduction to C++ IO Streams - October 10, 2011

Similar Threads

Assignment makes pointer from integer without a cast, warning: assignment makes integer from pointer without a cast, warning: assignment makes integer from pointer without a cast, ' assignment makes pointer from integer without a cast ".

  • C and C++ Programming at Cprogramming.com
  • Web Hosting
  • Privacy Statement

assignment to char from void makes integer from pointer without a cast wint conversion

  • Latest Articles
  • Top Articles
  • Posting/Update Guidelines
  • Article Help Forum

assignment to char from void makes integer from pointer without a cast wint conversion

  • View Unanswered Questions
  • View All Questions
  • View C# questions
  • View C++ questions
  • View Javascript questions
  • View Visual Basic questions
  • View .NET questions
  • CodeProject.AI Server
  • All Message Boards...
  • Running a Business
  • Sales / Marketing
  • Collaboration / Beta Testing
  • Work Issues
  • Design and Architecture
  • Artificial Intelligence
  • Internet of Things
  • ATL / WTL / STL
  • Managed C++/CLI
  • Objective-C and Swift
  • System Admin
  • Hosting and Servers
  • Linux Programming
  • .NET (Core and Framework)
  • Visual Basic
  • Web Development
  • Site Bugs / Suggestions
  • Spam and Abuse Watch
  • Competitions
  • The Insider Newsletter
  • The Daily Build Newsletter
  • Newsletter archive
  • CodeProject Stuff
  • Most Valuable Professionals
  • The Lounge  
  • The CodeProject Blog
  • Where I Am: Member Photos
  • The Insider News
  • The Weird & The Wonderful
  • What is 'CodeProject'?
  • General FAQ
  • Ask a Question
  • Bugs and Suggestions

My C program returns error? Warning: initialization makes integer from pointer without a cast [-wint-conversion]|? help!

assignment to char from void makes integer from pointer without a cast wint conversion

3 solutions

  • Most Recent

Add your solution here

Your Email  
Password  
Your Email  
?
Optional Password  
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Print

Top Experts
Last 24hrsThis month
55
10
-2
-2
-6
431
225
123
120
110

assignment to char from void makes integer from pointer without a cast wint conversion

C语言assignment makes pointer from integer without a cast

assignment to char from void makes integer from pointer without a cast wint conversion

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

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

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

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

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

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

assignment to char from void makes integer from pointer without a cast wint conversion

请填写红包祝福语或标题

assignment to char from void makes integer from pointer without a cast wint conversion

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

assignment to char from void makes integer from pointer without a cast wint conversion

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

assignment to char from void makes integer from pointer without a cast wint conversion

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

assignment to char from void makes integer from pointer without a cast wint conversion

Nordic DevZone

  • Online Power Profiler
  •  > 
  • Nordic Q&A
  • State Verified Answer
  • Replies 7 replies
  • Subscribers 66 subscribers
  • Views 6590 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?

  • 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 to 'int' from 'void *' makes integer from pointer without a cast

I am trying to make a linked list stack, and I followed a tutorial online, however I get this warning, and the author does not.

During debugging I get a segmentation fault, if I don't use malloc in the initialize function. MINGW-W64 compiler.

Konrad Rudolph's user avatar

  • 1 You seem to miss a bit of code. This doesn't even have a main, so we can't run this code to see your problem. –  MSalters Commented Oct 26, 2020 at 10:52
  • NULL is often (but not always) defined as #define NULL ((void *)0) , which would lead to the warning in the assignment s->data = NULL; since s->data has type int . Perhaps you should use s->data = 0; instead. Also, you do not show how function Initialize is called, but the argument corresponding to parameter s is ignored by the function. –  Ian Abbott Commented Oct 26, 2020 at 10:55
  • Either there is something wrong in function Initialize or the function argument stack *s is useless and should be replaced with a local variable. The value s passed to the function is immediately overwritten with the result of malloc . The caller of Initialize will not get the modified value as the pointer s is passed by value. 2nd problem: You should check the return value of malloc . If it returns a NULL pointer, the following accesses to s->data and s->next are invalid. –  Bodo Commented Oct 26, 2020 at 10:58
  • The function argument is useless, since you assign the pointer to the global stack *top; –  Weather Vane Commented Oct 26, 2020 at 11:00
  • 1 @Sumsar It is evident that the author of the tutorial is a low-qualified programmer.:) –  Vlad from Moscow Commented Oct 26, 2020 at 11:07

2 Answers 2

The warning is due to the fact the the NULL macro is defined (by most modern compilers) as ((void *)0) , as it is intended to be used only for pointers. Assigning this value to the data member of your structure causes the warning.

To remove this warning, use s->data=0; in place of s->data=NULL; . The author of the tutorial is either using an older compiler or has disabled this particular warning.

Also, the pointer ( s ) passed to your Initialize function will be a copy of whatever variable you use as an argument when you call that function and, as such, its value is not updated in the calling code. You haven't specified how you intend to use that function, but here is a (perhaps) better implementation:

And then, when you call that function, you can assign its returned value to your 'global' top pointer:

Adrian Mole's user avatar

  • You could use something like: stack *test = Initialize (); and then add an assert(test != NULL) before your other checks. –  Adrian Mole Commented Oct 26, 2020 at 11:29

In C the macro NULL is defined like

that is the type of the expression is a null pointer of the type void * .

Thus in this statement

a pointer is assigned to an object of the type int and the compiler issues a message saying that you are doing something wrong.

The function Initialize as it is written does not make a sense. Apart of all for example this statement

does not change the original pointer top used as the function argument.

In fact the function is redundant.

Nevertheless if to write such a function then it can look either like

and called like

Or for a new created node it can be declared and defined like

Vlad from Moscow'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 pointers memory struct or ask your own question .

  • The Overflow Blog
  • One of the best ways to get value for AI coding tools: generating tests
  • The world’s largest open-source business has plans for enhancing LLMs
  • Featured on Meta
  • User activation: Learnings and opportunities
  • Site maintenance - Mon, Sept 16 2024, 21:00 UTC to Tue, Sept 17 2024, 2:00...
  • What does a new user need in a homepage experience on Stack Overflow?
  • Announcing the new Staging Ground Reviewer Stats Widget

Hot Network Questions

  • What is the shortest viable hmac for non-critical applications?
  • PCB layout guidelines Magnetic Sensor
  • Why Pythagorean theorem is all about 2?
  • In this page of Ein Yaakov on Sotah, near the bottom of the page, appears the word "Piska" in bold lettering. What does it signify?
  • The consequence of a good letter of recommendation when things do not work out
  • How can I analyze the anatomy of a humanoid species to create sounds for their language?
  • Why was Panama Railroad in poor condition when US decided to build Panama Canal in 1904?
  • Novel where people kill duplicates of themselves on a spacecraft to trick an enemy
  • cat file contents to clipboard over ssh and across different OS
  • Is it feasible to create an online platform to effectively teach college-level math (abstract algebra, real analysis, etc.)?
  • Is it a correct rendering of Acts 1,24 when the New World Translation puts in „Jehovah“ instead of Lord?
  • How to prove that the Greek cross tiles the plane?
  • Philosophical dogma hindering scientific progress?
  • Definition of annuity
  • For a bike with "Forged alloy crank with 44T compact disc chainring", can the chainring be removed?
  • How can I support a closet rod where there's no shelf?
  • Does hydrogen peroxide work as a rocket fuel oxidizer by itself?
  • mmrm R package : No optimizer led to a successful model fit
  • Emacs calc: Apply function to vector
  • What would the natural diet of Bigfoot be?
  • Is it possible to change the AirDrop location on my Mac without downloading random stuff from the internet?
  • Analog of Birkhoff's HSP theorem regarding ultraproducts and elementary sublattices
  • What film is it where the antagonist uses an expandable triple knife?
  • If Act A repeals another Act B, and Act A is repealed, what happens to the Act B?

assignment to char from void makes integer from pointer without a cast wint conversion

  • 気になるQ&A

assignment to char from void makes integer from pointer without a cast wint conversion

  • アプリでもっと教えて!goo

推しミネラルウォーターはありますか?

  • 教えて!goo  >
  • コンピューター・テクノロジー  >
  • プログラミング・Web制作  >

入力中の回答があります。ページを離れますか?

※ページを離れると、回答が消えてしまいます

入力中のお礼があります。ページを離れますか?

※ページを離れると、お礼が消えてしまいます

assignment to char from void makes integer from pointer without a cast wint conversion

C言語のポインターに関する警告

  • 質問者: arm34fsa
  • 質問日時: 2008/12/11 12:08

line[100]で 「1」が格納されていたら「a」 「2」が格納されていたら「b」 「3」が格納されていたら「c」 とout[100]に代入する関数を作りたいのですが コンパイルすると関数の部分で warning: assignment makes integer from pointer without a cast という警告がでます。 ポインターは使っていないのですが、ポインターに関する警告が出ているようで困っています。 どこが悪いのかまったくわからなくて作業が完全に止まってしまいました。 解決法をおしえてください。お願いします。 /*宣言*/ int=i; /*main関数内のfor文で使用*/ char line[100], out[100]; void change(int); /*関数*/ void change(int i)   {    if(line[i]=='1'){     out[10]="a\0"    }if(line[i]=='2'){     out[10]="b\0";    }if(line[i]=='3'){     out[10]="c\0" } }

この質問への回答は締め切られました。

A 同じカテゴリの新着質問

A 回答   (2件)

assignment to char from void makes integer from pointer without a cast wint conversion

No.1 ベストアンサー

  • 回答者: chie65536
  • 回答日時: 2008/12/11 12:22

>    out[10]="a\0"

good

回答ありがとうございます。 "a\0"という書き方がまずかったのですか。 以後気をつけます。

assignment to char from void makes integer from pointer without a cast wint conversion

  • 回答者: buriburi3
  • 回答日時: 2008/12/11 12:27

char型の領域 out[10] に

まだまだ勉強中の身で「strcpy」というのを、今回はじめて知りました。 とても役に立つ知識をおしえていただきありがとうございます。

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!

このQ&Aを見た人はこんなQ&Aも見ています

assignment to char from void makes integer from pointer without a cast wint conversion

都道府県の名前を1人1つずつ投稿してください。全ての都道府県が出たら締め切ります!

フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?

フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?

あなたが普段思っている「これまだ誰も言ってなかったけど共感されるだろうな」というあるあるを教えてください

映画のエンドロール観る派?観ない派?

映画のエンドロール観る派?観ない派?

映画が終わった後、すぐに席を立って帰る方もちらほら見かけます。皆さんはエンドロールの最後まで観ていきますか?

海外旅行から帰ってきたら、まず何を食べる?

海外旅行から帰ってきたら、まず何を食べる?

帰国して1番食べたくなるもの、食べたくなるだろうなと思うもの、皆さんはありますか?

天使と悪魔選手権

悪魔がこんなささやきをしていたら、天使のあなたはなんと言って止めますか?

assignment to char from void makes integer from pointer without a cast wint conversion

C言語初心者の質問失礼します。

assignment to char from void makes integer from pointer without a cast wint conversion

C言語のポインターで詰まっている

assignment to char from void makes integer from pointer without a cast wint conversion

エラーの意味は? Lvalue required

assignment to char from void makes integer from pointer without a cast wint conversion

ポインター引数の関数でコンパイルエラーが出る。

Enterキーを押されたら次の処理に移るという事をしたい。

gcc: incompatible pointer type

<unistd.h>をVisualStudioでつかえるようにする

 ポインタを使って関数の値のやり取り

構造体のメンバをfor文で回したい

fgetsなどのときのstdinのバッファを消すには?

数字以外が入力されたらエラー文を出したい。

c言語です コンパイルした時に出るNOTEとはなんですか??

その他(プログラミング・Web制作)

C言語 exitの使い方

文字列から空白を取り除きたいのですが

構造体の各データの表示について以下のようなプログラムを作成しました。

【C言語】戻り値が構造体の関数

c言語のポインタへの文字列入力についてです。

関連するカテゴリからQ&Aを探す

Visual basic(vba), microsoft asp.

ページトップ

  • ・ 漫画をレンタルでお得に読める!
  • ・ 街中で見かけて「グッときた人」の思い出
  • ・ 「一気に最後まで読んだ」本、教えて下さい!
  • ・ 幼稚園時代「何組」でしたか?
  • ・ 激凹みから立ち直る方法
  • ・ 1つだけ過去を変えられるとしたら?
  • ・ 【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
  • ・ 【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
  • ・ 映画のエンドロール観る派?観ない派?
  • ・ 海外旅行から帰ってきたら、まず何を食べる?
  • ・ 誕生日にもらった意外なもの
  • ・ ちょっと先の未来クイズ第2問
  • ・ 【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
  • ・ 推しミネラルウォーターはありますか?
  • ・ 都道府県穴埋めゲーム
  • ・ この人頭いいなと思ったエピソード
  • ・ ゆるやかでぃべーと タイムマシンを破壊すべきか。
  • ・ 許せない心理テスト
  • ・ 字面がカッコいい英単語
  • ・ これ何て呼びますか Part2
  • ・ 人生で一番思い出に残ってる靴
  • ・ ゆるやかでぃべーと すべての高校生はアルバイトをするべきだ。
  • ・ 初めて自分の家と他人の家が違う、と意識した時
  • ・ チョコミントアイス

Q&Aの参照履歴

このQ&Aを見た人がよく見るQ&A

  • 配列を含む構造体の初期値について
  • C言語での引数の省略方法
  • 4 C言語 配列の長さの上限
  • 5 C言語にて構造体のメンバがNULL...
  • 7 main.c:7:43: warning: implici...
  • 8 関数から配列を返すには?
  • 9 printf による16進表示について
  • 10 DWORDの実際の型は何でしょうか
  • 11 C言語 関数プロトタイプ宣言の...
  • 12 テキストファイルの行数を取得...
  • 13 *をユーザーが入力した数字の数...
  • 14 c言語で任意のファイルから読み...
  • 15 strcat関数を自作したいです
  • 16 C言語でヘッダファイルにグロー...
  • 17 C言語のポインターで詰まっている
  • 18 コンパイルエラー invalid ope...
  • 19 コンパイルエラーに出てくる、i...
  • 20 10個出力で改行したいのですが...

デイリーランキング このカテゴリの人気デイリーQ&Aランキング

[java]try 内の変数を外で!?, jspやサーブレットでsystem.out..., エクスクラメーション2つ?, eclipseでjava, メール送信を行うjavaプログラム, 「続行するには何かキーを押し..., javaのdouble型の小数点以下の..., vb6 オブジェクトライブラリは..., "awt-eventqueue-0"java.lang.n..., lc発振回路-ループ利得, エクセルマクロ文で、赤文字セ..., java シンボルが見つかりません..., ipアドレスから組織やプロバイ..., path型をstring型へ変換する(java), if関数でempty値を設定する方法。, system.err. printlnとsystem.o..., 変数を動的に利用するには?, マンスリーランキング このカテゴリの人気マンスリーq&aランキング, 構文解析中にファイルの終わり..., java int integer, javaのプログラムがどうしても..., javaのコマンドライン引数を使..., javaでカレントディレクトリを....

質問して、直接聞いてみよう!

Q次郎

gooで dポイント がたまる!つかえる!

dアカウントでログイン

gooのご利用に応じてdポイントがたまる!つかえる!

ログインはdアカウントがおすすめです。 詳細はこちら

  • 新規登録する (無料)

教えて!gooの新規会員登録の方法が新しくなりました。

  • 1 gooID 新規登録
  • 3 ニックネーム 登録
  • 4 教えて!goo 会員登録 完了!

gooサービス全体で利用可能な「gooID」をご登録後、「電話番号」と「ニックネーム」の登録をすることで、教えて!gooの会員登録が完了となり、投稿ができるようになります!​

閉じる

gooIDにログイン済みです

教えて!goo 新規会員登録 (無料)

  • 1 gooID 新規登録 ログイン済
  • 2 電話番号 登録 次はここ!

閉じる

IMAGES

  1. assignment makes integer from pointer without a cast

    assignment to char from void makes integer from pointer without a cast wint conversion

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

    assignment to char from void makes integer from pointer without a cast wint conversion

  3. Making An Integer From A Pointer Without A Cast: A Comprehensive Guide

    assignment to char from void makes integer from pointer without a cast wint conversion

  4. Making An Integer From A Pointer Without A Cast: A Comprehensive Guide

    assignment to char from void makes integer from pointer without a cast wint conversion

  5. [Solved] Assignment makes integer from pointer without a

    assignment to char from void makes integer from pointer without a cast wint conversion

  6. Solved error: assignment makes pointer from integer without

    assignment to char from void makes integer from pointer without a cast wint conversion

VIDEO

  1. Arrays in C++ Understanding Decay and Pointer Conversion

  2. 6.Integer Data Type In C Part

  3. pointer without the wig 😂

  4. #012

  5. Fundamental vs Derived Data Types

  6. Maw of the Void brutal speedrun 3:46

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. How to fix

    I need to remove all the commas from my user input. The code is working but it's giving the warning "assignment to 'char' from 'char *' makes integer from pointer without a cast". I need to get rid of this warning.

  3. 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."

  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 (Resolved)

    Solving Assignment Makes Integer from Pointer Without a Cast in C: Tips and Solutions

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

    If you read this far, tweet to the author to show them you care. Tweet a Thanks

  7. [SOLVED] C

    Re: C - assigment makes integer from pointer without a cast warning. path [1] is the second element of a char array, so it's a char. home is a char *, i.e. a pointer to a char. You get the warning because you try to assign a char* to a char. Note also the potential to overflow your buffer if the content of the argv [1] argument is very long.

  8. Assignment makes pointer from integer without a cast

    Assignment makes pointer from integer without a cast Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: Assignment makes pointer from integer without a cast

  9. [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);

  10. 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 ...

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

    Strings literals are pointers in C. When you a sentence like "Hello world!", that variable is of the type const char*, meaning it is a pointer to a bunch of chars that cannot be modified. When you use double-quotes, you are making a const char*, even if there is only one character. You should use single-quotes if you want to have a char.

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

    To add onto this, if you're wanting to compare a single character (here '-' and '+'), you'll want to use single quotes rather than double quotes. Single quotes indicate characters (char), whilst double quotes indicate null-terminated strings (char *).

  13. My C program returns error? Warning: initialization makes integer from

    warning: initialization makes integer from pointer without a cast [-Wint-conversion]| What I have tried: I have tried stackoverflow,I have also looked all over google but couldnt find the awnser.I also tried quora

  14. 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;

  15. 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.

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

    近日遇见一个bug,最后调查是程序的warning引起的: 编译的时候报警告: assignment makes pointer from integer without a cast 出现这个警告的原因是在使用函数之前没有对函数进行声明,未经声明的函数原型一律默认为返回int值。就相当于你调用了返回值为int的函数,并将其赋给了char*变量,所有会出现警告。

  17. 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 ()).

  18. 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 ...

  19. assignment to 'int' from 'void *' makes integer from pointer without a cast

    Either there is something wrong in function Initialize or the function argument stack *s is useless and should be replaced with a local variable. The value s passed to the function is immediately overwritten with the result of malloc.The caller of Initialize will not get the modified value as the pointer s is passed by value. 2nd problem: You should check the return value of malloc.

  20. C言語のポインターに関する警告

    warning: assignment makes integer from pointer without a cast という警告がでます。 ポインターは使っていないのですが、ポインターに関する警告が出ているようで困っています。 どこが悪いのかまったくわからなくて作業が完全に止まってしまいました。

  21. 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 ...