Thread: Error-size of te type is unknown

  1. #1
    Registered User
    Join Date
    Aug 2010
    Location
    Pune
    Posts
    3

    Question Error-size of te type is unknown

    i written this program. but m not getting what the error means in this.. will anyone explain me where is the error n what modification i got to do if any..???


    Code:
    #include<stdio.h>
    #include<conio.h>
    
    typedef struct sparse
    {
     int row;
     int col;
     int val;
    }s;
    
    s s1[10],s2[10],s3[20];
    
    void read(int m1[][],int r1,int c1);
    void display(s s1[],int m1[][],int r1,int c1);
    
    
    
    void main()
     {
      int r1,c1,r2,c2,m1[4][4],m2[4][4],op=0;
    
      printf("\nEnter the no. of rows and column in 1st matrix");
      scanf("%d %d",&r1,&c1);
      read(m1,r1,c1);
      printf("\nEnter the no. of rows and columns in the 2nd matrix");
      scanf("%d %d",&r2,&c2);
      read(m2,r2,c2);
    
      do
      {
       printf("\n\n1.Represent both in tuples form.");
       printf("\n2.Addition of two sparse matrices");
       printf("\n3.Simple transpose of matrices");
       printf("\n4.Fast transpose of matrices");
       printf("\nEnter your choice");
       scanf("%d",&op);
    
       switch(op)
    
        {
          case 1: printf("\n1st matrix is:: \n");
    	      display(s1,m1,r1,c1);
    	      printf("\n2nd matrix is:: \n");
    	      display(s2,m2,r2,c2);
    	      break;
    
          case 2: printf("\nAddition of two sparse matrices is:: \n");
    	      addition(s1,s2,s3);
    	      break;
    
    
         }
         printf("\nDo you want to continue?y/n");
    
       }while((getche()=='y')||(getche()=='Y'));
    
     }
    
    
    void read(int m1[4][4],int r1,int c1)
    {
     int i,j;
    
     for(i=0;i<r1;i++)
      {
       for(j=0;j<c1;j++)
        {
         scanf("%d",&m1[i][j]);
        }
      }
    }
    
    
    void display(s s1[10],int m1[4][4],int r1,int c1)
    {
     int i,j,k=1;
    
     for(i=0;i<r1;i++)
      {
       for(j=0;j<c1;j++)
        {
         if(m1[i][j]!=0)
          {
           s1[k].row=i;
           s1[k].col=j;
           s1[k].val=m1[i][j];
           k++;
          }
        }
       }
       s1[0].row=r1;
       s1[0].col=c1;
       s1[0].val=k-1;
    
       for(i=0;i<k;i++)
        {
         printf("\n\t%d\t %d\t %d\n",s1[i].row,s1[i].col,s1[i].val);
        }
    
    }
    Compiling errors:
    error SPA1.CPP 13: Size of the type is unknown or zero
    error SPA1.CPP 14: Size of the type is unknown or zero
    error SPA1.CPP 60: Size of the type is unknown or zero
    error SPA1.CPP 68: Size of the type is unknown or zero
    error SPA1.CPP 74: Size of the type is unknown or zero
    error SPA1.CPP 82: Size of the type is unknown or zero
    error SPA1.CPP 86: Size of the type is unknown or zero

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Earlier typedef info was wrong. Problem is the function prototype with m[][]. That SO crashes my system (although it compiles without error, oddly).

    To make it work, I had to put values into those square brackets after m (at least the last one is a must, the first index number is optional).


    Also, (maybe you know this), but you appear to be using a c++ compiler. If you want C, then tell your IDE to switch compilers (usually, if you change the program's filename to an extension of .c, that is enough to cause the change).

    And int main() with a return 0 at the end.
    Last edited by Adak; 08-28-2010 at 04:12 PM.

  3. #3
    Registered User
    Join Date
    Aug 2010
    Location
    Pune
    Posts
    3

    Question

    but the erroe is not with the struct thing.
    that part is correct.
    its showing error at 'int r1' in prototype of read n display function. and and at their function call. also at the scanf statement of read function its showing same error in 'm[i][j]'.
    is there any error in passing the parameter m1 i.e. matrix??

  4. #4
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    From the C-FAQ

    6.18
    6.19

  5. #5
    Registered User
    Join Date
    Aug 2010
    Location
    Pune
    Posts
    3
    hey thanks got the answer.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Adak View Post
    Earlier typedef info was wrong. Problem is the function prototype with m[][]. That SO crashes my system (although it compiles without error, oddly).
    Tried a modern compiler? Visual Studio barks at it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Conversion of pointers to functions
    By hzmonte in forum C Programming
    Replies: 0
    Last Post: 01-20-2009, 01:56 AM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  3. Can you check what is wrong with this code
    By Ron in forum C++ Programming
    Replies: 4
    Last Post: 08-01-2008, 10:59 PM
  4. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  5. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM