Thread: Its Late...Due Tonight....Help Please

  1. #1
    Unregistered
    Guest

    Question Its Late...Due Tonight....Help Please

    #include <stdio.h>

    struct assignment6{
    int num;
    char ch;
    int num_array[10];
    char name[30];
    int* int_ptr;
    char* char_ptr;
    };

    typedef struct assignment6 assign6;

    assign6 enterdata(assign6 var);
    void showdata(assign6 var);

    int x=0;
    int y;

    int main ()
    {
    int request;
    assign6 inst1,inst2,inst3,inst4,inst5;

    for (int x=0; x<5; x++)
    {
    thingy[x].num=0;
    }

    do
    {
    printf("Enter the instance you wish to modify or Press 9 to quit");
    scanf("%d",request);
    switch (request)
    {
    case 1:
    {
    enterdata(&inst1);
    inst1.num = 1;
    inst1.ch = 'A';
    inst1.int_ptr=&(inst1.num_array[4]);
    inst1.char_ptr=&(inst1.name[4]);
    }
    case 2:
    {
    enterdata(&inst2);
    inst2.num = 2;
    inst2.ch = 'B';
    inst2.int_ptr=&(inst2.num_array[4]);
    inst2.char_ptr=&(inst2.name[4]);
    }
    case 3:
    {
    enterdata(&inst3);
    inst3.num = 3;
    inst3.ch = 'C';
    inst3.int_ptr=&(inst3.num_array[4]);
    inst3.char_ptr=&(inst3.name[4]);
    }
    case 4:
    {
    enterdata(&inst4);
    inst4.num = 4;
    inst4.ch = 'D';
    inst4.int_ptr=&(inst4.num_array[4]);
    inst4.char_ptr=&(inst4.name[4]);
    }
    case 5:
    {
    enterdata(&inst5);
    inst5.num = 5;
    inst5.ch = 'E';
    inst5.int_ptr=&(inst5.num_array[4]);
    inst5.char_ptr=&(inst5.name[4]);
    }
    case 9: break;
    default: printf("You did not enter 1-5 or 9 run program again.\n");
    }
    }
    while (request != 9);
    for (x =0; x<5; x++)
    {
    printf("This is instance %d",x);
    showdata(thingy[x]);
    }
    return 0;
    }


    assign6 enterdata(assign6 var)
    {
    for (x=0; x<10; x++)
    {
    printf("Enter the entry number %d for the array:",x);
    scanf("%d",&(x->num_array[x]));
    }
    for (x=0; x<30; x++)
    {
    printf("Enter a string:");
    scanf("%c",&(x->name[x]));
    }
    return x;
    }



    void showdata(assign6 var)
    {
    int tmp;

    if (var.num == 0)
    {
    printf("This Instance is Empty");
    }
    else
    {
    for(x=0; x<9; x++)
    {
    for (int y=1; y < 10; y++)
    {
    if (var.num_array[y] < var.num_array[x])
    {
    tmp = var.num_array[y];
    var.num_array[y]=var.num_array[x];
    var.num_array[x]=tmp;
    }
    }
    }

    printf("The sorted array is:");

    for (x=0; x<10; x++)
    {
    printf("%d ", var.num_array[x]);
    }

    printf("The Reverse String Is:");

    for (x=29; x>=0; x--)
    {
    printf("%c ",var.name[x]);
    }

    printf("The fifth element of the integer array is located at %d",var.int_ptr);
    printf("The fifth element of the string is located at %d",var.char_ptr);
    }
    }


    this is my code, here is the link....

    http://www.cs.ucf.edu/~riqbal/assign6.html

    we are getting only errors, and very frustrated

    here are the errors:

    6test.c: In function `main':
    6test.c:29: parse error before `int'
    6test.c:29: parse error before `)'
    6test.c: At top level:
    6test.c:37: parse error before string constant
    6test.c:37: warning: data definition has no type or storage class
    6test.c:88: parse error before `['
    6test.c:88: conflicting types for `showdata'
    6test.c:15: previous declaration of `showdata'
    6test.c:88: warning: data definition has no type or storage class
    6test.c:95: conflicting types for `enterdata'
    6test.c:14: previous declaration of `enterdata'
    6test.c: In function `enterdata':
    6test.c:106: incompatible types in return
    6test.c: At top level:
    6test.c:112: conflicting types for `showdata'
    6test.c:88: previous declaration of `showdata'
    6test.c: In function `showdata':
    6test.c:123: parse error before `int'
    6test.c:123: parse error before `)'
    6test.c: At top level:
    6test.c:134: parse error before string constant
    6test.c:134: warning: data definition has no type or storage class
    6test.c:141: parse error before string constant
    6test.c:141: warning: data definition has no type or storage class
    6test.c:149: parse error before string constant
    6test.c:149: warning: data definition has no type or storage class
    6test.c:151: parse error before string constant
    6test.c:151: warning: data definition has no type or storage class

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    whats this....
    for (int x=0; x<5; x++)
    {
    thingy[x].num=0;
    }
    cant find a declaration for thingy[]

    parse errors are usually missing { or } or ( or ) or ;
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Unregistered
    Guest

    We declared Thingy

    We declared thingy and we still get the same errors...

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    Well, go through and look at the lines where the errors happen, or the lines just before.

    The first 2 errors are because you have this:

    for (int x=0; x<5; x++)

    but you already declared x (and cannot declare it here, in C) => drop the 'int'.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    35
    ah that code was soo bad, hahhahhaahahaha you failed your ass off so bad!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. This may be due to a corruption of the heap
    By krishnampkkm in forum C++ Programming
    Replies: 4
    Last Post: 06-26-2009, 03:19 AM
  2. Am I too late to learn programming?
    By maccat in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 02-17-2009, 08:49 AM
  3. Homework due tonight! help please!!
    By Andy717 in forum C++ Programming
    Replies: 41
    Last Post: 04-07-2005, 01:18 PM
  4. Help Someone! First program/errors and its due tonight!
    By LittleLotte in forum C Programming
    Replies: 4
    Last Post: 02-02-2005, 09:21 AM
  5. tonight... tonight...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 11-07-2001, 11:20 PM