Thread: simple question to an expert ?

  1. #1
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159

    Talking simple question to an expert ?

    how to use a *
    in a function
    the operator's function / * -> * / are she/it is useful for structures to affect by a *
    if yes how to use him correctly

  2. #2
    Welcome to the real world
    Join Date
    Feb 2004
    Posts
    50
    Code:
    void printString(char *strVal) {
        printf("This function printed the parameter char* strVal: %s", strVal);
    }
    
    int main (void) {
        strTest = "Let us see if this string gets printed.";
        printString(strTest);
    
        return 0;
    }
    The above code is a very small sample using a char* for a parameter in a function. Take the above and modify it to see if you can use arrays for parameters or pass an array to the function above - any which way you choose.

  3. #3
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159
    what about "->"

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    -> is for a pointer to a structure. Here is an example:
    Code:
    #include <stdio.h>
    
    struct myStruct
    {
      int value;
    };
    
    void foo(struct myStruct *mine)
    {
      mine->value = 11;
    }
    
    int main(void)
    {
      struct myStruct bar;
      
      foo(&bar);
      
      printf ("%d\n", bar.value);
      return(0);
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  2. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  3. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM