Thread: warning assignment makes interger from pointer without cast

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    808
    nope now whats wrong this was copied out of a book
    Code:
    int main()
    {
        int i;//, j, k;
        char *movies[3] = {"batman",
                           "gone in 60 seconds",
                           "get carter"};
    
    
        for (i = 0; i < 3; i++)
        {
            printf("%s\n",*movies[i]);
        }
    }
    this is getting beyond a joke
    coop

  2. #2
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    You've declared movies as an array of pointers to char:
    Quote Originally Posted by cooper1200
    Code:
    char *movies[3] = {"batman",
                       "gone in 60 seconds",
                       "get carter"};
    And trying to print individual chars (printf expects a pointer due to "%s") -- line 11:
    Quote Originally Posted by cooper1200
    Code:
    printf("%s\n",*movies[i]);
    The correct printf() call should be:
    Code:
    printf("%s\n", movies[i]);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 04-09-2014, 09:19 PM
  2. Replies: 4
    Last Post: 03-03-2010, 01:06 PM
  3. Replies: 1
    Last Post: 12-23-2008, 09:39 AM
  4. Replies: 17
    Last Post: 02-13-2006, 01:19 PM
  5. Replies: 3
    Last Post: 01-14-2002, 12:13 PM

Tags for this Thread