printing characters stored in variables [duplicate]Char (single letter) must be a pointer to correctly work?Is an array name a pointer?Arrays are Pointers?What does this guide mean by “And since arrays are actually pointers”?Incompatible integer to pointer conversion assigning to 'char *' from 'int'Why is my program not compiling?Getting warnings when assigning characters to a 2d array declared using malloc in CInitialising integer array as memberVigénere Cipher in C+ or - sign in array, CIn C89, I can't seem to make a character array from an existing oneWhile executing this program the char function does the returning the variable.i dont know why?Why do I get this error and warning? Error and warning is in the description

C++ logging library

How to avoid typing 'git' at the begining of every git command

I have a problematic assistant manager, but I can't fire him

Why are MBA programs closing in the United States?

How do we say "within a kilometer radius spherically"?

Sci-fi novel: ark ship from Earth is sent into space to another planet, one man woken early from cryosleep paints a giant mural

What would prevent chimeras from reproducing with each other?

Teaching a class likely meant to inflate the GPA of student athletes

Live action TV show where High school Kids go into the virtual world and have to clear levels

Why is Na5 not played in this line of the French Defense, Advance Variation?

Getting UPS Power from One Room to Another

Solving ‘Null geometry…’ error during distance matrix operation?

A map of non-pathological topology?

How can I make 12 tone and atonal melodies sound interesting?

Was Self-modifying-code possible just using BASIC?

Grep Match and extract

Is using 'echo' to display attacker-controlled data on the terminal dangerous?

Analogy between an unknown in an argument, and a contradiction in the principle of explosion

Does the new finding on "reversing a quantum jump mid-flight" rule out any interpretations of QM?

Amplitude of a crest and trough in a sound wave?

Russian word for a male zebra

Why does this query, missing a FROM clause, not error out?

How to hide rifle during medieval town entrance inspection?

Increase speed altering column on large table to NON NULL



printing characters stored in variables [duplicate]


Char (single letter) must be a pointer to correctly work?Is an array name a pointer?Arrays are Pointers?What does this guide mean by “And since arrays are actually pointers”?Incompatible integer to pointer conversion assigning to 'char *' from 'int'Why is my program not compiling?Getting warnings when assigning characters to a 2d array declared using malloc in CInitialising integer array as memberVigénere Cipher in C+ or - sign in array, CIn C89, I can't seem to make a character array from an existing oneWhile executing this program the char function does the returning the variable.i dont know why?Why do I get this error and warning? Error and warning is in the description






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0
















This question already has an answer here:



  • Char (single letter) must be a pointer to correctly work?

    1 answer



I can't get my function to print characters i have initialised and declared.



#include <stdio.h>
int main()

char letter1 ="i";
char letter2 ="n";
char letter3 ="C";

printf ("Programming %c%c %cn", letter1, letter2, letter3);


return 0;



I want it to display



 "Programming in C"


using



 printf ("Programming %c%c %cn", letter1, letter2, letter3);


I get the following error



main.c:4:8: warning: incompatible pointer to integer conversion 
initializing 'char' with an expression of type 'char [2]' [-Wint-
conversion]
char letter1 ="i";
^


I haven't learn about pointers or anything yet, I'm used to simpler languages that just work. I am trying to go through an edX course but I find the quality to be poor and the pacing tedious.



Would be happy if you could help me out here and recommend me better resources for learning C



thanks










share|improve this question













marked as duplicate by melpomene, Daniel Pryden, Antti Haapala c
Users with the  c badge can single-handedly close c questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 21:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 3





    "i" is a string literal, you want character literals, which use a single quote 'i': en.cppreference.com/w/c/language/character_constant

    – UnholySheep
    Mar 24 at 20:23












  • I didn't even know there was a difference, thanks it works now <3

    – Mr_Bodger
    Mar 24 at 20:24











  • Or change char to char * and then do printf ("Programming %c%c %cn", *letter1, *letter2, *letter3); (otherwise character literals use single-quotes while string literals use double-quotes)

    – David C. Rankin
    Mar 24 at 20:47


















0
















This question already has an answer here:



  • Char (single letter) must be a pointer to correctly work?

    1 answer



I can't get my function to print characters i have initialised and declared.



#include <stdio.h>
int main()

char letter1 ="i";
char letter2 ="n";
char letter3 ="C";

printf ("Programming %c%c %cn", letter1, letter2, letter3);


return 0;



I want it to display



 "Programming in C"


using



 printf ("Programming %c%c %cn", letter1, letter2, letter3);


I get the following error



main.c:4:8: warning: incompatible pointer to integer conversion 
initializing 'char' with an expression of type 'char [2]' [-Wint-
conversion]
char letter1 ="i";
^


I haven't learn about pointers or anything yet, I'm used to simpler languages that just work. I am trying to go through an edX course but I find the quality to be poor and the pacing tedious.



Would be happy if you could help me out here and recommend me better resources for learning C



thanks










share|improve this question













marked as duplicate by melpomene, Daniel Pryden, Antti Haapala c
Users with the  c badge can single-handedly close c questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 21:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 3





    "i" is a string literal, you want character literals, which use a single quote 'i': en.cppreference.com/w/c/language/character_constant

    – UnholySheep
    Mar 24 at 20:23












  • I didn't even know there was a difference, thanks it works now <3

    – Mr_Bodger
    Mar 24 at 20:24











  • Or change char to char * and then do printf ("Programming %c%c %cn", *letter1, *letter2, *letter3); (otherwise character literals use single-quotes while string literals use double-quotes)

    – David C. Rankin
    Mar 24 at 20:47














0












0








0









This question already has an answer here:



  • Char (single letter) must be a pointer to correctly work?

    1 answer



I can't get my function to print characters i have initialised and declared.



#include <stdio.h>
int main()

char letter1 ="i";
char letter2 ="n";
char letter3 ="C";

printf ("Programming %c%c %cn", letter1, letter2, letter3);


return 0;



I want it to display



 "Programming in C"


using



 printf ("Programming %c%c %cn", letter1, letter2, letter3);


I get the following error



main.c:4:8: warning: incompatible pointer to integer conversion 
initializing 'char' with an expression of type 'char [2]' [-Wint-
conversion]
char letter1 ="i";
^


I haven't learn about pointers or anything yet, I'm used to simpler languages that just work. I am trying to go through an edX course but I find the quality to be poor and the pacing tedious.



Would be happy if you could help me out here and recommend me better resources for learning C



thanks










share|improve this question















This question already has an answer here:



  • Char (single letter) must be a pointer to correctly work?

    1 answer



I can't get my function to print characters i have initialised and declared.



#include <stdio.h>
int main()

char letter1 ="i";
char letter2 ="n";
char letter3 ="C";

printf ("Programming %c%c %cn", letter1, letter2, letter3);


return 0;



I want it to display



 "Programming in C"


using



 printf ("Programming %c%c %cn", letter1, letter2, letter3);


I get the following error



main.c:4:8: warning: incompatible pointer to integer conversion 
initializing 'char' with an expression of type 'char [2]' [-Wint-
conversion]
char letter1 ="i";
^


I haven't learn about pointers or anything yet, I'm used to simpler languages that just work. I am trying to go through an edX course but I find the quality to be poor and the pacing tedious.



Would be happy if you could help me out here and recommend me better resources for learning C



thanks





This question already has an answer here:



  • Char (single letter) must be a pointer to correctly work?

    1 answer







c






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 20:21









Mr_BodgerMr_Bodger

141




141




marked as duplicate by melpomene, Daniel Pryden, Antti Haapala c
Users with the  c badge can single-handedly close c questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 21:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by melpomene, Daniel Pryden, Antti Haapala c
Users with the  c badge can single-handedly close c questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 21:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 3





    "i" is a string literal, you want character literals, which use a single quote 'i': en.cppreference.com/w/c/language/character_constant

    – UnholySheep
    Mar 24 at 20:23












  • I didn't even know there was a difference, thanks it works now <3

    – Mr_Bodger
    Mar 24 at 20:24











  • Or change char to char * and then do printf ("Programming %c%c %cn", *letter1, *letter2, *letter3); (otherwise character literals use single-quotes while string literals use double-quotes)

    – David C. Rankin
    Mar 24 at 20:47













  • 3





    "i" is a string literal, you want character literals, which use a single quote 'i': en.cppreference.com/w/c/language/character_constant

    – UnholySheep
    Mar 24 at 20:23












  • I didn't even know there was a difference, thanks it works now <3

    – Mr_Bodger
    Mar 24 at 20:24











  • Or change char to char * and then do printf ("Programming %c%c %cn", *letter1, *letter2, *letter3); (otherwise character literals use single-quotes while string literals use double-quotes)

    – David C. Rankin
    Mar 24 at 20:47








3




3





"i" is a string literal, you want character literals, which use a single quote 'i': en.cppreference.com/w/c/language/character_constant

– UnholySheep
Mar 24 at 20:23






"i" is a string literal, you want character literals, which use a single quote 'i': en.cppreference.com/w/c/language/character_constant

– UnholySheep
Mar 24 at 20:23














I didn't even know there was a difference, thanks it works now <3

– Mr_Bodger
Mar 24 at 20:24





I didn't even know there was a difference, thanks it works now <3

– Mr_Bodger
Mar 24 at 20:24













Or change char to char * and then do printf ("Programming %c%c %cn", *letter1, *letter2, *letter3); (otherwise character literals use single-quotes while string literals use double-quotes)

– David C. Rankin
Mar 24 at 20:47






Or change char to char * and then do printf ("Programming %c%c %cn", *letter1, *letter2, *letter3); (otherwise character literals use single-quotes while string literals use double-quotes)

– David C. Rankin
Mar 24 at 20:47













2 Answers
2






active

oldest

votes


















0














 char letter1 ="i";


Unfortunately, "i" is a string. Use 'i' for characters or "i"[0] if you really want to.



If your compiler didn't give you a warning, it's either a terrible compiler or you don't have appropriate warnings turned on. If you got a warning and you ignored it ...






share|improve this answer






























    -2














    Arrays in C are pointers to the first element. All other elements in the array follows the first element on stack stack. Strings in C are represented by char arrays. Therefore, following example will work:



    char str[3];
    str[0] = 'A';
    str[1] = 'B';
    str[2] = 'C';


    Fortunately, C allows a shorthand for representing strings. Following are two examples:



    char str[] = "ABC";
    char str* = "ABC";


    As previously mentioned, arrays are pointers. Therefore, both examples work. Also, note that we don't have enter a size of the array as we directly initialize the array.



    If you really want to print a string only using char variables, then you have to use quotes, like the example below:



    letter1 = 'A';
    letter2 = 'B';
    letter3 = 'C';


    As literature, I highly recommend the book Problem Solving and Program Design in C by Hanly Koffman. It is simple to read and has a lot of code examples.






    share|improve this answer


















    • 1





      Arrays are not pointers

      – Blastfurnace
      Mar 24 at 22:36












    • As I said, an array is a pointer to the first element.

      – Martin Pekár
      Mar 25 at 8:09











    • Arrays are not, in fact, pointers. For example, given the definitions char arr[1], *ptr; it's a fact that sizeof(arr) != sizeof(ptr) and arr = ptr; is a syntax error. The array and the pointer are not the same types. I can find more questions/answers on Stack Overflow if you aren't convinced.

      – Blastfurnace
      Mar 25 at 8:37











    • Well, sizeof in C will return the amount of bytes for the data types times amount of element in the array. So, of course, they are not equal, since you have to get the address of an element in the array and compare its address size to the size of the pointer. And yes, ´arr=ptr´ is a syntax error, but the opposite ´ptr=arr´ is not. Technicallly, an array of a compile time specific size is allocated in the %rsp register, which is then pushed onto the stack. An array is a pointer to the first element in the %rsp register. To get the next element on the stack, add the byte size to the address.

      – Martin Pekár
      Mar 25 at 10:52











    • Also, why do you dynamically allocate memory in a pointer...?

      – Martin Pekár
      Mar 25 at 10:57

















    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














     char letter1 ="i";


    Unfortunately, "i" is a string. Use 'i' for characters or "i"[0] if you really want to.



    If your compiler didn't give you a warning, it's either a terrible compiler or you don't have appropriate warnings turned on. If you got a warning and you ignored it ...






    share|improve this answer



























      0














       char letter1 ="i";


      Unfortunately, "i" is a string. Use 'i' for characters or "i"[0] if you really want to.



      If your compiler didn't give you a warning, it's either a terrible compiler or you don't have appropriate warnings turned on. If you got a warning and you ignored it ...






      share|improve this answer

























        0












        0








        0







         char letter1 ="i";


        Unfortunately, "i" is a string. Use 'i' for characters or "i"[0] if you really want to.



        If your compiler didn't give you a warning, it's either a terrible compiler or you don't have appropriate warnings turned on. If you got a warning and you ignored it ...






        share|improve this answer













         char letter1 ="i";


        Unfortunately, "i" is a string. Use 'i' for characters or "i"[0] if you really want to.



        If your compiler didn't give you a warning, it's either a terrible compiler or you don't have appropriate warnings turned on. If you got a warning and you ignored it ...







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 20:25









        David SchwartzDavid Schwartz

        141k14149237




        141k14149237























            -2














            Arrays in C are pointers to the first element. All other elements in the array follows the first element on stack stack. Strings in C are represented by char arrays. Therefore, following example will work:



            char str[3];
            str[0] = 'A';
            str[1] = 'B';
            str[2] = 'C';


            Fortunately, C allows a shorthand for representing strings. Following are two examples:



            char str[] = "ABC";
            char str* = "ABC";


            As previously mentioned, arrays are pointers. Therefore, both examples work. Also, note that we don't have enter a size of the array as we directly initialize the array.



            If you really want to print a string only using char variables, then you have to use quotes, like the example below:



            letter1 = 'A';
            letter2 = 'B';
            letter3 = 'C';


            As literature, I highly recommend the book Problem Solving and Program Design in C by Hanly Koffman. It is simple to read and has a lot of code examples.






            share|improve this answer


















            • 1





              Arrays are not pointers

              – Blastfurnace
              Mar 24 at 22:36












            • As I said, an array is a pointer to the first element.

              – Martin Pekár
              Mar 25 at 8:09











            • Arrays are not, in fact, pointers. For example, given the definitions char arr[1], *ptr; it's a fact that sizeof(arr) != sizeof(ptr) and arr = ptr; is a syntax error. The array and the pointer are not the same types. I can find more questions/answers on Stack Overflow if you aren't convinced.

              – Blastfurnace
              Mar 25 at 8:37











            • Well, sizeof in C will return the amount of bytes for the data types times amount of element in the array. So, of course, they are not equal, since you have to get the address of an element in the array and compare its address size to the size of the pointer. And yes, ´arr=ptr´ is a syntax error, but the opposite ´ptr=arr´ is not. Technicallly, an array of a compile time specific size is allocated in the %rsp register, which is then pushed onto the stack. An array is a pointer to the first element in the %rsp register. To get the next element on the stack, add the byte size to the address.

              – Martin Pekár
              Mar 25 at 10:52











            • Also, why do you dynamically allocate memory in a pointer...?

              – Martin Pekár
              Mar 25 at 10:57















            -2














            Arrays in C are pointers to the first element. All other elements in the array follows the first element on stack stack. Strings in C are represented by char arrays. Therefore, following example will work:



            char str[3];
            str[0] = 'A';
            str[1] = 'B';
            str[2] = 'C';


            Fortunately, C allows a shorthand for representing strings. Following are two examples:



            char str[] = "ABC";
            char str* = "ABC";


            As previously mentioned, arrays are pointers. Therefore, both examples work. Also, note that we don't have enter a size of the array as we directly initialize the array.



            If you really want to print a string only using char variables, then you have to use quotes, like the example below:



            letter1 = 'A';
            letter2 = 'B';
            letter3 = 'C';


            As literature, I highly recommend the book Problem Solving and Program Design in C by Hanly Koffman. It is simple to read and has a lot of code examples.






            share|improve this answer


















            • 1





              Arrays are not pointers

              – Blastfurnace
              Mar 24 at 22:36












            • As I said, an array is a pointer to the first element.

              – Martin Pekár
              Mar 25 at 8:09











            • Arrays are not, in fact, pointers. For example, given the definitions char arr[1], *ptr; it's a fact that sizeof(arr) != sizeof(ptr) and arr = ptr; is a syntax error. The array and the pointer are not the same types. I can find more questions/answers on Stack Overflow if you aren't convinced.

              – Blastfurnace
              Mar 25 at 8:37











            • Well, sizeof in C will return the amount of bytes for the data types times amount of element in the array. So, of course, they are not equal, since you have to get the address of an element in the array and compare its address size to the size of the pointer. And yes, ´arr=ptr´ is a syntax error, but the opposite ´ptr=arr´ is not. Technicallly, an array of a compile time specific size is allocated in the %rsp register, which is then pushed onto the stack. An array is a pointer to the first element in the %rsp register. To get the next element on the stack, add the byte size to the address.

              – Martin Pekár
              Mar 25 at 10:52











            • Also, why do you dynamically allocate memory in a pointer...?

              – Martin Pekár
              Mar 25 at 10:57













            -2












            -2








            -2







            Arrays in C are pointers to the first element. All other elements in the array follows the first element on stack stack. Strings in C are represented by char arrays. Therefore, following example will work:



            char str[3];
            str[0] = 'A';
            str[1] = 'B';
            str[2] = 'C';


            Fortunately, C allows a shorthand for representing strings. Following are two examples:



            char str[] = "ABC";
            char str* = "ABC";


            As previously mentioned, arrays are pointers. Therefore, both examples work. Also, note that we don't have enter a size of the array as we directly initialize the array.



            If you really want to print a string only using char variables, then you have to use quotes, like the example below:



            letter1 = 'A';
            letter2 = 'B';
            letter3 = 'C';


            As literature, I highly recommend the book Problem Solving and Program Design in C by Hanly Koffman. It is simple to read and has a lot of code examples.






            share|improve this answer













            Arrays in C are pointers to the first element. All other elements in the array follows the first element on stack stack. Strings in C are represented by char arrays. Therefore, following example will work:



            char str[3];
            str[0] = 'A';
            str[1] = 'B';
            str[2] = 'C';


            Fortunately, C allows a shorthand for representing strings. Following are two examples:



            char str[] = "ABC";
            char str* = "ABC";


            As previously mentioned, arrays are pointers. Therefore, both examples work. Also, note that we don't have enter a size of the array as we directly initialize the array.



            If you really want to print a string only using char variables, then you have to use quotes, like the example below:



            letter1 = 'A';
            letter2 = 'B';
            letter3 = 'C';


            As literature, I highly recommend the book Problem Solving and Program Design in C by Hanly Koffman. It is simple to read and has a lot of code examples.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 24 at 20:42









            Martin PekárMartin Pekár

            274




            274







            • 1





              Arrays are not pointers

              – Blastfurnace
              Mar 24 at 22:36












            • As I said, an array is a pointer to the first element.

              – Martin Pekár
              Mar 25 at 8:09











            • Arrays are not, in fact, pointers. For example, given the definitions char arr[1], *ptr; it's a fact that sizeof(arr) != sizeof(ptr) and arr = ptr; is a syntax error. The array and the pointer are not the same types. I can find more questions/answers on Stack Overflow if you aren't convinced.

              – Blastfurnace
              Mar 25 at 8:37











            • Well, sizeof in C will return the amount of bytes for the data types times amount of element in the array. So, of course, they are not equal, since you have to get the address of an element in the array and compare its address size to the size of the pointer. And yes, ´arr=ptr´ is a syntax error, but the opposite ´ptr=arr´ is not. Technicallly, an array of a compile time specific size is allocated in the %rsp register, which is then pushed onto the stack. An array is a pointer to the first element in the %rsp register. To get the next element on the stack, add the byte size to the address.

              – Martin Pekár
              Mar 25 at 10:52











            • Also, why do you dynamically allocate memory in a pointer...?

              – Martin Pekár
              Mar 25 at 10:57












            • 1





              Arrays are not pointers

              – Blastfurnace
              Mar 24 at 22:36












            • As I said, an array is a pointer to the first element.

              – Martin Pekár
              Mar 25 at 8:09











            • Arrays are not, in fact, pointers. For example, given the definitions char arr[1], *ptr; it's a fact that sizeof(arr) != sizeof(ptr) and arr = ptr; is a syntax error. The array and the pointer are not the same types. I can find more questions/answers on Stack Overflow if you aren't convinced.

              – Blastfurnace
              Mar 25 at 8:37











            • Well, sizeof in C will return the amount of bytes for the data types times amount of element in the array. So, of course, they are not equal, since you have to get the address of an element in the array and compare its address size to the size of the pointer. And yes, ´arr=ptr´ is a syntax error, but the opposite ´ptr=arr´ is not. Technicallly, an array of a compile time specific size is allocated in the %rsp register, which is then pushed onto the stack. An array is a pointer to the first element in the %rsp register. To get the next element on the stack, add the byte size to the address.

              – Martin Pekár
              Mar 25 at 10:52











            • Also, why do you dynamically allocate memory in a pointer...?

              – Martin Pekár
              Mar 25 at 10:57







            1




            1





            Arrays are not pointers

            – Blastfurnace
            Mar 24 at 22:36






            Arrays are not pointers

            – Blastfurnace
            Mar 24 at 22:36














            As I said, an array is a pointer to the first element.

            – Martin Pekár
            Mar 25 at 8:09





            As I said, an array is a pointer to the first element.

            – Martin Pekár
            Mar 25 at 8:09













            Arrays are not, in fact, pointers. For example, given the definitions char arr[1], *ptr; it's a fact that sizeof(arr) != sizeof(ptr) and arr = ptr; is a syntax error. The array and the pointer are not the same types. I can find more questions/answers on Stack Overflow if you aren't convinced.

            – Blastfurnace
            Mar 25 at 8:37





            Arrays are not, in fact, pointers. For example, given the definitions char arr[1], *ptr; it's a fact that sizeof(arr) != sizeof(ptr) and arr = ptr; is a syntax error. The array and the pointer are not the same types. I can find more questions/answers on Stack Overflow if you aren't convinced.

            – Blastfurnace
            Mar 25 at 8:37













            Well, sizeof in C will return the amount of bytes for the data types times amount of element in the array. So, of course, they are not equal, since you have to get the address of an element in the array and compare its address size to the size of the pointer. And yes, ´arr=ptr´ is a syntax error, but the opposite ´ptr=arr´ is not. Technicallly, an array of a compile time specific size is allocated in the %rsp register, which is then pushed onto the stack. An array is a pointer to the first element in the %rsp register. To get the next element on the stack, add the byte size to the address.

            – Martin Pekár
            Mar 25 at 10:52





            Well, sizeof in C will return the amount of bytes for the data types times amount of element in the array. So, of course, they are not equal, since you have to get the address of an element in the array and compare its address size to the size of the pointer. And yes, ´arr=ptr´ is a syntax error, but the opposite ´ptr=arr´ is not. Technicallly, an array of a compile time specific size is allocated in the %rsp register, which is then pushed onto the stack. An array is a pointer to the first element in the %rsp register. To get the next element on the stack, add the byte size to the address.

            – Martin Pekár
            Mar 25 at 10:52













            Also, why do you dynamically allocate memory in a pointer...?

            – Martin Pekár
            Mar 25 at 10:57





            Also, why do you dynamically allocate memory in a pointer...?

            – Martin Pekár
            Mar 25 at 10:57



            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해