Find the answer to your Linux question:
Results 1 to 3 of 3
i'm a newbie ,i don't know where problems 未命名.jpg The results 未命1名.jpg...
  1. #1
    Just Joined! ibelieveme's Avatar
    Join Date
    Apr 2011
    Posts
    23

    C langage variable problem

    i'm a newbie ,i don't know where problems
    未命名.jpg

    The results
    未命1名.jpg

  2. #2
    Just Joined! pieman's Avatar
    Join Date
    Jan 2012
    Location
    Sunny Yorkshire
    Posts
    11
    You've got an extra & on line 6 that you shouldn't have.

    ss is declared as an array, so you want to pass the beginning of the array to the scanf() function. This is similar to the line below where you are printing out the array.

  3. #3
    Trusted Penguin Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,392
    You have a pointer-type problem.

    First, a little background... If you define an array:
    Code:
    char array[20];
    you generate a variable ('array') which acts as a pointer to the block of memory you allocated in the declaration. You can then do stuff like:
    Code:
    char* pointer =0;
    pointer = array;
    and now 'pointer' points at the same block of memory.

    So, if your method is calling for a 'char' pointer (i.e. a 'char *') then you just need to pass it the name of your array. In my examples from above, both these would be valid:

    Code:
    scanf("%s", array);
    scanf("%s", pointer);
    Linux user #126863 - see http://linuxcounter.net/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...