why i get these errors..

This is a discussion on why i get these errors.. within the C Programming forums, part of the General Programming Boards category; 1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(22) : error C2065: 'line' : undeclared identifier 1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(22) : ...

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    why i get these errors..

    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(22) : error C2065: 'line' : undeclared identifier
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(22) : error C2440: '=' : cannot convert from 'int' to 'line'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(22) : error C2146: syntax error : missing ';' before identifier 'next_Id'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2059: syntax error : '%'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2059: syntax error : 'bad suffix on number'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2059: syntax error : 'bad suffix on number'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2059: syntax error : 'bad suffix on number'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2059: syntax error : 'bad suffix on number'


    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
     
    
     
    struct line {
    	char name[21], address[21], ID[10];
    	int grade;
    	int code;
    };
    
    
    struct line next_Id(FILE * room , int last_ID);
    int main ()
    {
    FILE* c[2];
     struct line  temp;
    
    c[0]=fopen("c:\\fl1.txt","r");//vote files ,each file represents the votes from a college
    c[1]=fopen("c:\\fl2.txt","r");
    temp=line next_Id(c[0] , 666666666);
    fclose(c[0]);
    fclose(c[1]);
    
    
    
    	return 0;
    }
     /*
     struct line {
    	char name[21], address[21], ID[10];
    	int grade;
    	int code;
    };
    */
    struct line next_Id(FILE * room , int last_ID)
    {
        struct line  temp;
    	int flag;
    		flag=fscanf(room,%10s%10s%10s%10d%,temp->name,temp->address,temp->ID,&temp->grade,&temp->code);
    
    		return temp;
    }

  2. #2
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    i solved some
    but i get others instead??

    error C2059: syntax error : '%'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2059: syntax error : 'bad suffix on number'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2059: syntax error : 'bad suffix on number'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2059: syntax error : 'bad suffix on number'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2059: syntax error : 'bad suffix on number'

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
     
    
     
    struct line {
    	char name[21], address[21], ID[10];
    	int grade;
    	int code;
    };
    
    
    struct line next_Id(FILE * room , int last_ID);
    int main ()
    {
    FILE* c[2];
     struct line  temp;
    
    c[0]=fopen("c:\\fl1.txt","r");//vote files ,each file represents the votes from a college
    c[1]=fopen("c:\\fl2.txt","r");
    temp=next_Id(c[0] , 666666666);
    fclose(c[0]);
    fclose(c[1]);
    
    
    
    	return 0;
    }
     /*
     struct line {
    	char name[21], address[21], ID[10];
    	int grade;
    	int code;
    };
    */
    struct line next_Id(FILE * room , int last_ID)
    {
        struct line  temp;
    	int flag;
    		flag=fscanf(room,%10s%10s%10s%10d%,temp->name,temp->address,temp->ID,&temp->grade,&temp->code);
    
    		return temp;
    }

  3. #3
    Always learning
    Join Date
    Apr 2009
    Posts
    25
    There are many things wrong with your code.
    Code:
    temp=line next_Id(c[0] , 666666666);
    should be
    Code:
    temp= next_Id(c[0] , 666666666);
    Code:
    flag=fscanf(room,%10s%10s%10s%10d%,temp->name,temp->address,temp->ID,&temp->grade,&temp->code);
    should be
    Code:
    flag=fscanf(room,"%10s%10s%10s%10d%",temp.name,temp.address,temp.ID,&temp.grade,&temp.code);
    The important thing is that you must understand why. Don't continue unless you do!

  4. #4
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    i fixed it more
    but still i have this error in 5 places
    why??

    ex6.c(41) : error C2232: '->address' : left operand has 'struct' type, use '.'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2232: '->ID' : left operand has 'struct' type, use '.'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2232: '->grade' : left operand has 'struct' type, use '.'
    1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(41) : error C2232: '->code' : left operand has 'struct' type, use '.'
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
     
    
     
    struct line {
    	char name[21], address[21], ID[10];
    	int grade;
    	int code;
    };
    
    
    struct line next_Id(FILE * room , int last_ID);
    int main ()
    {
    FILE* c[2];
     struct line  temp;
    
    c[0]=fopen("c:\\fl1.txt","r");//vote files ,each file represents the votes from a college
    c[1]=fopen("c:\\fl2.txt","r");
    temp=next_Id(c[0] , 666666666);
    fclose(c[0]);
    fclose(c[1]);
    
    
    
    	return 0;
    }
     /*
     struct line {
    	char name[21], address[21], ID[10];
    	int grade;
    	int code;
    };
    */
    struct line next_Id(FILE * room , int last_ID)
    {
        struct line  temp;
    	int flag;
    		flag=fscanf(room,"%10s%10s%10s%10d%10d",temp->name,temp->address,temp->ID,&temp->grade,&temp->code);
    
    		return temp;
    }

  5. #5
    apprentiCe
    Join Date
    Oct 2008
    Location
    Hyderabad,India
    Posts
    136
    Code:
    temp=line next_Id(c[0] , 666666666);
    what are you doing here???

    and here???

    Code:
    flag=fscanf(room,"%10s%10s%10s%10d%10d",temp->name,temp->address,temp->ID,&temp->grade,&temp->code);
    Code:
    printf("%c%c%c%c%c%c%c",0x68,0x68^0xd,0x68|0x4,0x68|0x4,0x68|0xf,0x68^0x49,0x68^0x62);

  6. #6
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    there is no such thing as temp.name in C
    only *temp.name which is the same thing as temp->name

    so i cant see whats the problem
    ?

  7. #7
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    why its not letting me use "->" form
    i cant understand this massage
    '->grade' : left operand has 'struct' type, use '.'

    in binary trees and stuff i used it all the time both on the left and the right sides
    ??

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
     
    
     
    struct line {
    	char name[21], address[21], ID[10];
    	int grade;
    	int code;
    };
    
    
    struct line next_Id(FILE * room , int last_ID);
    int main ()
    {
    FILE* c[2];
     struct line  temp;
    
    c[0]=fopen("c:\\fl1.txt","r");//vote files ,each file represents the votes from a college
    c[1]=fopen("c:\\fl2.txt","r");
    temp=next_Id(c[0] , 666666666);
    fclose(c[0]);
    fclose(c[1]);
    
    
    
    	return 0;
    }
     /*
     struct line {
    	char name[21], address[21], ID[10];
    	int grade;
    	int code;
    };
    */
    struct line next_Id(FILE * room , int last_ID)
    {
        struct line  temp,max;
    	int flag;
    		flag=fscanf(room,"%10s%10s%10s%10d%10d%*c",&temp.name,&temp.address,&temp.ID,&temp.grade,&temp.code);
            while (flag!=5)
    		{
               flag=fscanf(room,"%10s%10s%10s%10d%10d%*c",&max.name,&max.address,&max.ID,&max.grade,&max.code);
                 if (max->grade)
    		}
    		return temp;
    }

  8. #8
    apprentiCe
    Join Date
    Oct 2008
    Location
    Hyderabad,India
    Posts
    136
    Quote Originally Posted by transgalactic2 View Post
    there is no such thing as temp.name in C
    only *temp.name which is the same thing as temp->name

    so i cant see whats the problem
    ?
    LOLOLOL!!!! please see this Cprogramming.com Tutorial: Structures
    Code:
    printf("%c%c%c%c%c%c%c",0x68,0x68^0xd,0x68|0x4,0x68|0x4,0x68|0xf,0x68^0x49,0x68^0x62);

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,704
    max is not a pointer.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    ahhhh thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  2. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 02:57 PM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  4. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 08:18 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 05:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21