1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Basic C programming

Discussion in 'Programming' started by vivekgupta143, Jun 11, 2012.

  1. #1
    Why don't we use '&' in the case of strings in function scanf ??

    e.g. :-


    scanf("%s",date);


    Plz help
     
    vivekgupta143, Jun 11, 2012 IP
  2. a9entropy

    a9entropy Member

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    A string in C is basically a Character Array.
    And the name of an array always points to the first block of data that it holds.
    so when I type
    char a[10] = "Hello";

    a always points to the start of the array. So it's the address.
    Whereas in case of integers
    int a = 10;
    a is actually the variable that holds the value. And the address is given by &a
     
    a9entropy, Jun 19, 2012 IP
  3. abstract_thoughts

    abstract_thoughts Greenhorn

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    The & is used to provide the memory address of the variable. So for a variable x, its address is &x.
    In case of strings, the name of the array is infact a point to the string in memory.
    So mentioning its name as an argument is enough.
     
    abstract_thoughts, Jun 19, 2012 IP
  4. Noahdduke

    Noahdduke Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    c language is very large language. it is very famous language.This is the combination of Cobol and Fotrait language.C language syntax is also clear and use of pointer is very powerful tools.
     
    Noahdduke, Jun 27, 2012 IP
  5. kimie4546

    kimie4546 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    hi friend..anybody can help me about code sensor detect and make output lcd count?
     
    kimie4546, Jun 28, 2012 IP
  6. lolpasslol

    lolpasslol Peon

    Messages:
    860
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hei Mr. kimie4546 please it is not place of joking.

    Ans:
    this is very clear ,it is not a variable ,so &(ampersand) is ignored.
     
    lolpasslol, Jul 17, 2012 IP
  7. dylanrodriguez2012

    dylanrodriguez2012 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hello Guys.

    So my conclusion would be if you have a free hand (and there may well be good reasons why this isn't the case), use Visual Basic. If, on the other hand, you've got a team of C or Java legacy programmers who insist on using a language with case-sensitive variables, then let them use Visual C#.

    All your comment for programming development are welcome.

    For More Info :- www.aegisisc.com

    Thanks in advance.
     
    dylanrodriguez2012, Jul 18, 2012 IP
  8. HowardBeck

    HowardBeck Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    C is father of all language ,and they crate some rules for crating any program.In c language "&" is use for the provide address for particular website,so ypou can nout yse for other use.If use for other purpose you get the error on your program.
     
    HowardBeck, Jul 18, 2012 IP
  9. Bernardcwood

    Bernardcwood Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Programming in C is one of the thousands of programming languages ​​that allow users to create instructions for a computer to follow. While C has a style a bit more cryptic than other programming languages​​, it is quite easy to learn and lets you read and write code for different platforms. Because it is so efficient and gives the user great control, C is popular among programmers.
     
    Bernardcwood, Jul 18, 2012 IP
  10. sudhavishwakarmacis

    sudhavishwakarmacis Greenhorn

    Messages:
    24
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    23
    #10
    I completely agree to what a9entropy has replied. Address-of(&) operator is used to address the memory location of the variable.
     
    sudhavishwakarmacis, Jul 20, 2012 IP
  11. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #11
    In C and C++ * is a pointer and & is a reference and both refer to memory locations, as others have pointed out. There is a subtle difference, that being that a pointer can be changed and is stored in a variable, whereas a reference cannot be changed and is stored in a constant. A pointer also has its own memory address whereas a reference does not.

    In other words, a reference is more direct, the most direct location of a variable's memory address, whereas you can have pointers to pointers to pointers etc..

    So a reference is a memory address's lowest level of abstraction whereas a pointer is a slightly higher level and can have many indirections.

    A reference is accessed via the full stop '.' whereas a pointer is accessed via '->'.

    References cannot be put in an array, whereas pointers can.

    Gah, I miss playing with pointers and references :) High level languages like PHP and C# don't really allow the use of them.
     
    Last edited: Jul 21, 2012
    BRUm, Jul 21, 2012 IP
  12. akhilesh kanodia

    akhilesh kanodia Greenhorn

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #12
    hi vivek gupta
    in C & is address operator. any variable like x then &x is hold the address of variable x. so it use for store value of x . but in case of string, string is a character array so every character have one address like x[10] is a character array x[0],x[1]...hold one character so x not hold character it is use for hold address of first character(&x[0]) . so we use only variable name that hold address of first character.
     
    akhilesh kanodia, Aug 13, 2012 IP
  13. ashleyjohn2347

    ashleyjohn2347 Peon

    Messages:
    269
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Well said. Proper answer. :)
     
    ashleyjohn2347, Aug 16, 2012 IP