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 Mythbuntu
  • Get Edubuntu
  • Get Ubuntu GNOME
  • 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

Thread: [solved] c - assigment makes integer from pointer without a cast warning, thread tools.

  • Show Printable Version
  • Subscribe to this Thread…
  • 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

strdup assignment makes pointer from integer without a cast

assignment makes pointer from integer without a cast

Member Avatar for axn

Errors when compiling. its seem to be complaining about line 52 and i do not get output of second file.(data.words) strarray[numStrings++]=strdup(word);

$ gcc -Wall -ansi prt.c -o prt In function ‘main’: warning: implicit declaration of function ‘strdup’ warning: assignment makes pointer from integer without a cast

  • 4 Contributors
  • 1 Week Discussion Span
  • Latest Post 12 Years Ago Latest Post by Ancient Dragon

Recommended Answers Collapse Answers

remove the -ansi flag and you won't get those warnings. The only reason I know of to use -ansi it to compile old lagecy code, written last century.

Where is strdup() defined? How is it defined? It's not an ANSI function.

All 6 Replies

Member Avatar for Ancient Dragon

I already tried that, it works but I get seg fault. I am running on x86_64 x86_64 x86_64 GNU/Linux

kinda have to be executed with -ansi, per instructor. Any other ideas??

ahh! something I never expected. Thanks for the tip

Member Avatar for chrjs

strdup is part of the GNU C library which can be found basically every linux machine. It is a declared inside of string.h. It duplicates a string like strcpy, but uses malloc so it can be freed later.

I just tried to compile that code on Ubantu and got the same errors. If you look at /usr/include/string.h you will see that strdup() is conditionally defined

As Walt already said strdup() is not an ansi function. You will have to remove the -ansi flag from the command line options in order to use strdup(), or define one of the macros in the #if statement.

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.

Insert Code Block

C语言assignment makes pointer from integer without a cast

strdup assignment makes pointer from integer without a cast

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

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

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

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

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

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

strdup assignment makes pointer from integer without a cast

“相关推荐”对你有帮助么?

strdup assignment makes pointer from integer without a cast

请填写红包祝福语或标题

strdup assignment makes pointer from integer without a cast

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

strdup assignment makes pointer from integer without a cast

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

strdup assignment makes pointer from integer without a cast

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

strdup assignment makes pointer from integer without a cast

C Board

passing argument 1 of 'strlen' makes pointer from integer without a cast

Printable View

I write code witch generate file name based on: destination directory settings, radio station presets list and current time. If users store radio station name (app presets) with white space in name: Europa FM Paprika Radio Radio France Internationale ........................... Rock FM I want to remove whitespace for recording radio station filename and result look like this: /home/ubuntu/Desktop/EuropaFM_07042012-111705.ogg Code: static int start_recording(const gchar *destination, const char* station, const char* time) {     Recording* recording;     char *filename;     char* remove_whitespace(station)     {         char* result = malloc(strlen(station)+1);         char* i;         int temp = 0;         for( i = station; *i; ++i)             if(*i != ' ')             {                 result[temp] = (*i);                 ++temp;             }         result[temp] = '\0';         return result;     }     filename = g_strdup_printf(_("%s/%s_%s"),         destination,         remove_whitespace(station),         time);     recording = recording_start(filename);     g_free(filename);     if (!recording)         return -1;     recording->station = g_strdup(station);     tray_icon_items_set_sensible(FALSE);     record_status_window(recording);     run_status_window(recording);     return 1; } But this get warnings: warning: passing argument 1 of 'strlen' makes pointer from integer without a cast [enabled by default] warning: assignment makes pointer from integer without a cast [enabled by default] I appreciate your help. Thanks.
O_o Missing ';' can cause unusual problems... Soma
Please explain the following snippet: Code: char* remove_whitespace(station)     {         char* result = malloc(strlen(station)+1);         char* i;         int temp = 0;         for( i = station; *i; ++i)             if(*i != ' ')             {                 result[temp] = (*i);                 ++temp;             }         result[temp] = '\0';         return result;     } To me this looks like a function implementation. inside another function, using a default integer parameter. Which should explain the error message. Several problems, one never implement a function inside a function. Two never use default parameters when defining, implementing functions. Three you probably have a memory leak because you aren't assigning the value being returned to any variable. Jim
Quote: Originally Posted by jimblumberg Please explain the following snippet: Code: char* remove_whitespace(station)     {         char* result = malloc(strlen(station)+1);         char* i;         int temp = 0;         for( i = station; *i; ++i)             if(*i != ' ')             {                 result[temp] = (*i);                 ++temp;             }         result[temp] = '\0';         return result;     } To me this looks like a function implementation. inside another function, using a default integer parameter. Which should explain the error message. Several problems, one never implement a function inside a function. Two never use default parameters when defining, implementing functions. Three you probably have a memory leak because you aren't assigning the value being returned to any variable. Jim Maybe solution is to remove whitespace here? Code: void rec_button_clicked_cb(GtkButton *button, gpointer app) {     char *station;     char time_str[100];     time_t t;         t = time(NULL);     /* consult man strftime to translate this. This is a filename, so don't use "/" or ":", please */     strftime(time_str, 100, _("%m%d%Y-%H%M%S"), localtime(&t));         if (mom_ps < 0) {         station = g_strdup_printf(_("%.2f MHz"), rint(gtk_adjustment_get_value(adj))/STEPS);     } else {         g_assert(mom_ps < g_list_length(settings.presets));         preset* ps = g_list_nth_data(settings.presets, mom_ps);         g_assert(ps);             station = g_strdup(ps->title);     }
Quote: Maybe solution is to remove whitespace here? I don't know, maybe here, maybe there. That is a decision you need to make. I didn't see anything wrong about where you were trying to remove the whitespace in your original post, just the method used. As to where you remove the whitespace, that is a design decision that you the programmer must make. Jim
Because you have not specified the type of parameter station in the remove_whitespace function declaration, it defaults to an int . I'd recommend using a simple file name sanitizer instead, which also prepends the specified directory name (NULL if none) to yield the full path to the target file. Code: #include <stdlib.h> #include <string.h> #include <errno.h> static inline char *path_to(const char *const dir, const char *const name) {     const size_t  dirlen = (dir) ? strlen(dir) : 0;     const size_t  namelen = (name) ? strlen(name) : 0;     char        *result;     const unsigned char *s;     unsigned char *d;     /* Empty name is not allowed. */     if (namelen < 1) {         errno = EINVAL;         return NULL;     }     result = malloc(dirlen + namelen + 4);     if (!result) {         errno = ENOMEM;         return NULL;     }     d = (unsigned char *)result;     if (namelen > 0) {         s = (const unsigned char *)dir;         if (*s != '/')             *(d++) = '.';         while (1) {             while (*s == '/')                 s++;             if (!*s)                 break;             *(d++) = '/';             while (*s && *s != '/')                 *(d++) = *(s++);         }       *(d++) = '/';     }     s = (const unsigned char *)name;     while (*s)         if (*s <= 32 || *s == 47 || *s == 127)             s++; /* Skip whitespace, control chars, and slashes */         else             *(d++) = *(s++);     /* Terminate path. */     *d = '\0';     /* Empty result? */     if ((char *)d == result) {         free(result);         errno = EINVAL;         return NULL;     }     /* Empty file name part? */     if (*(d - 1) == '/') {         free(result);         errno = EINVAL;         return NULL;     }     return result; } The above one does not sanitize the directory part, only the file name part. ASCII control characters, ASCII whitespace, and slashes (/) are removed from the file name part. If a path can be constructed safely, it is returned as a dynamically allocated string. After you no longer need it, you must remember to free() the returned pointer. If the function cannot construct a path to a file, it will return NULL, with errno set to indicate the reason: ENOMEM if out of memory, and EINVAL if the file name part is empty. It is safe to call the function with NULL parameters. The directory may be NULL; the path generated will then have no directory part. (If the directory part is empty, the result will start with ./ , i.e. current directory). The file name part must not be empty, or be empty after sanitization, or the function will return NULL with errno set to EINVAL. In your particular case, I'd use Code: /* Instead of 'time' to the function, pass a pointer to GDateTime: */ GDateTime *now; g_char *temptime, *tempname; char *path; temptime = g_date_time_format(_("%x %X"), now); if (!temptime)     return 0; /* Out of memory, or localization error */ tempname = g_strdup_printf(_("%1$s_%2$s"), station, temptime); g_free(temptime); if (!tempname)     return 0; /* Out of memory, or localization error */ path = path_to((const char *)destination, (const char *)tempname); if (!path) {     /* errno == EINVAL: Invalid file name (possibly bad localization),     * errno == ENOMEM: Out of memory.     */     g_free(tempname);     return 0; /* Out of memory, invalid file name, or localization error */ } g_free(tempname); /* Record to file 'path' ... */ free(path); return 1; /* Success */ This way the way time is used in the file names is localizable. It should default to full date and time according to the current locale. Also, the way the station name and date-time is combined to form the file name is localizable. Whatever we get after the two localization steps, we feed through the function I showed above, to construct the full path to the target file. For example, if I localized that to Finnish, I'd use YYYYMMDD-hhmm- station by using %Y%m%d-%H%M and %2$s-%1$s in the .po file. Note how the above calls g_free() and free() to discard the dynamically allocated temporaries when they're no longer used. It will not leak memory even if an error occurs. (For future reference: It is very useful to remember that both g_free(NULL) and free(NULL) are safe; they do nothing. If you start getting complicated if clauses at the error conditions, just initialize all dynamically allocated temporaries to NULL, and in all exit cases just free them all unconditionally. Elsewhere, when you free something, also assign the pointer to NULL. It is safe, and yields quite readable code, although some programmers complain about how the "superfluous" free()s and g_free()s hurt their eyes or something.)

Welcome to the new Microchip Forum! All previous communities hosted on  https://www.microchip.com/forums  are now being redirected to  https://forum.microchip.com . Please carefully review and follow the site  login instructions  and important information related to  users of AVR Freaks and Microchip Forum sites , including retired Atmel sites.

  • Menu About Community Forums

strdup assignment makes pointer from integer without a cast

The routine below draws an image on a tft-screen, and although the whole programm works fine and the image is displayed ok, I'm unable to resolve this 'assignment' warning at pS=pS0+n; .

I've tried several casts, but as yet not the right one (I'm not so well versed in casting).

Can anyone help with the solution?

Definition of the image:

Drawing the image:

The actual routine:

strdup assignment makes pointer from integer without a cast

pS0 should have the same type as pS (const char *), and definitely not unsigned int.

TNKernel-PIC32, an open-source real-time kernel for the PIC32

strdup assignment makes pointer from integer without a cast

I don't understand why you have ps0 defined as...

If you define it as the correct type, you can avoid all the ugly and unecessary casting:

Edit: andersm beat me to it.

It also seems a lot of your variables are incorrectly sized.  rgb8 could easily be unsigned char, for example.

strdup assignment makes pointer from integer without a cast

You are trying to convert an pointer to an integer without cast and it is simply telling you that the correct type is what pS type is that is the thing that line is trying to set after all

That all said it would be a hell of a lot easier to make PS0 a const char* and simply tell it

Thank you all for the replies. I think this will help me resolve it. And the the other tips too!

strdup assignment makes pointer from integer without a cast

404 Not found

IMAGES

  1. Array : Assignment makes integer from pointer without a cast [-Wint

    strdup assignment makes pointer from integer without a cast

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

    strdup assignment makes pointer from integer without a cast

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

    strdup assignment makes pointer from integer without a cast

  4. assignment makes integer from pointer without a cast

    strdup assignment makes pointer from integer without a cast

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

    strdup assignment makes pointer from integer without a cast

  6. [Solved] Initialization makes pointer from integer

    strdup assignment makes pointer from integer without a cast

VIDEO

  1. Delete without head pointer

  2. MODULE 5

  3. LeetCode Streak

  4. embedded systems 12: C Programming

  5. Pseudocode for the Class-Average Problem

  6. 4. "C" Pointers and Character Strings

COMMENTS

  1. c

    I'm using the function 'strdup' to insert a char* into a char** and getting the search.c:174:13: warning: assignment makes pointer from integer without a cast [enabled by default] warning. char** ...

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

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

  4. [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.

  5. Question to do with strdup()

    Now, my question is, I got a compiler warning complaining that 'assignment makes pointer from integer without cast', for this line: nptr->nick = strdup(s); I fixed it with: nptr->nick = (void *)strdup(s); However, whilst I've fixed the warning, I don't quite understand why lol. Could someone explain to me why the warning is now gone? I know it ...

  6. C assign value to char pointer in struct

    Assignment make pointer from integer without cast. Ah, I thought strdup() was a C standard function - turns out it's a POSIX/BSD function. You can easily implement it with something like: ... then called strdup on buf and cast the return as char*, this seemed to clear it up. Code: node->students[n].name = (char*)strdup(buf);

  7. strdup(): Confused about warnings ('implicit declaration', 'makes

    Stack Overflow People questions & answers; Stack Overflow for Teams Where device & technologists share private knowledge with coworkers; Skills Build your employer brand ; Advertising Reach developers & engineers wide; Labs The future of collective knowledge sharing; About the company

  8. passing argument 1 of 'strlen' makes pointer from integer without a cast

    After you no longer need it, you must remember to free () the returned pointer. If the function cannot construct a path to a file, it will return NULL, with errno set to indicate the reason: ENOMEM if out of memory, and EINVAL if the file name part is empty. It is safe to call the function with NULL parameters.

  9. C error

    n.c:29:18: warning: assignment makes integer from pointer without a cast [enabled by default] firstInitial = "A"; ^ n.c:30:19: warning: assignment makes integer from pointer without a cast [enabled by default] secondInitial = "J"; ^

  10. assignment makes pointer from integer without ...

    warning: assignment makes pointer from integer without a cast 1 ; warning: passing argument 2 of ‘write’ makes pointer from integer without a cast 2 ; applet and database operation 5 ; Replace a substring by a new substring (makes pointer of integer withou a cast) 6 ; Mouse Coordinates, Object Locations, and Saving? HELP!? 2

  11. C Language, implicit declaration of strdup

    foo.c: In function `main': foo.c:9: warning: implicit declaration of function `strdup'. foo.c:9: assignment makes pointer from integer without a cast. I understand the meaning of the warnings, but can't imagine why. gcc is complaining about strdup, except if strdup. is not defined in ANSI C.

  12. c

    Stacked Overflow Popular questions & answers; Stack Overflow for Teams Where developers & engineering part private knowledge with coworkers; Talent Build your employer brand ; Advertising Reach developers & technologists worldwide; Workshops The future of collective knowledge sharing; About the company

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

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

  14. passing argument 1 of 'strlen' makes pointer from integer without a cast

    Buda. passing argument 1 of 'strlen' makes pointer from integer without a cast. I write code witch generate file name based on: destination directory settings, radio station presets list and current time. If users store radio station name (app presets) with white space in name: Europa FM. Paprika Radio.

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

  16. Assignment makes pointer from integer without a cast

    You are trying to convert an pointer to an integer without cast and it is simply telling you that the correct type is what pS type is that is the thing that line is trying to set after all. pS = (const char *) (pS0+n) That all said it would be a hell of a lot easier to make PS0 a const char* and simply tell it.

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

  18. c

    Your compiler doesn't have a declaration of strdup, because you didn't #include any header store declaring it. Having no declaration, the gatherer guessed that strdup would returns an int. You allocating the result from calling strdup to a clock variable. Include the right header file, and your problems shall at least get less.

  19. passing argument makes pointer from integer without a cast

    #define CharSize 1 // in case running on other systems—char has always a size of 1, even on non-8 bit systems. Thus, int string_len = sizeof(*checkstring) / CharSize; always evaluates to 1, on all systems. You need to pass the length of an array to a function as a separate parameter, or use a function like strlen if your array has some sentinel value (like a 0-byte for a string): size_t ...

  20. warning: assignment makes integer from pointer without a cast

    menu-0.5.c:623: warning: assignment makes integer from pointer without a cast menu-0.5.c:624: warning: format argument is not a pointer (arg 2) I dont understand why it says i am assigning integer from pointer when i have declared nArgsPtr as a char ( char *nArgsPtr) Does anyone know what I am doing wrong here? Thanks Martin-