Solving Assignment Makes Integer from Pointer Without a Cast in C: Tips and Solutions
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
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
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.
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.
- 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
- 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
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
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
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
- 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
- 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
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 .
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!
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).
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
- 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
- Latest Articles
- Top Articles
- Posting/Update Guidelines
- Article Help Forum
- 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!
3 solutions
- Most Recent
IMAGES
VIDEO
COMMENTS
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 ...
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.
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."
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;
Solving Assignment Makes Integer from Pointer Without a Cast in C: Tips and Solutions
If you read this far, tweet to the author to show them you care. Tweet a Thanks
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.
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
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);
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 ...
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.
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 *).
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
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;
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.
近日遇见一个bug,最后调查是程序的warning引起的: 编译的时候报警告: assignment makes pointer from integer without a cast 出现这个警告的原因是在使用函数之前没有对函数进行声明,未经声明的函数原型一律默认为返回int值。就相当于你调用了返回值为int的函数,并将其赋给了char*变量,所有会出现警告。
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 ()).
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 ...
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.
warning: assignment makes integer from pointer without a cast という警告がでます。 ポインターは使っていないのですが、ポインターに関する警告が出ているようで困っています。 どこが悪いのかまったくわからなくて作業が完全に止まってしまいました。
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 ...