Thread: struct data input problem..

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    struct data input problem..

    when i got a normal struct variable code:
    Code:
    struct human { 
      char name[50]; 
      int age; 
      float height; 
    };
    
    struct human TR = {"Tony", 12, 1.5};   \\this works
    but when my object is a part of an array and i take just one object
    the same data input method doesnt work
    why is that?
    Code:
    #include <stdio.h>
    
    typedef struct robot ROBOT;
    
    struct robot { 
      char *name; 
      int energy; 
    };
    
    int main() {
      int i;
      
      ROBOT robots[3];
    
      
       robots[0] = {"Lunar Lee", 50};  //this  dont work
    Last edited by transgalactic2; 10-24-2008 at 03:33 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  2. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM
  5. Problem with Printing message
    By robert_sun in forum C Programming
    Replies: 2
    Last Post: 05-16-2004, 02:09 PM