Random Error Message

This is a discussion on Random Error Message within the C Programming forums, part of the General Programming Boards category; Hi - I'm having the most random problem. I've got a header file readfile.h and in it is a structure ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    24

    Random Error Message

    Hi -

    I'm having the most random problem.

    I've got a header file readfile.h and in it is a structure I've created

    Code:
    #ifndef _READFILE_H_
    #define _READFILE_H_
    #include "vectorlist.h"
    
    
    typedef struct tagFileNames{
    	char fileName[20];
    }tagFileNames;
    
    
    /*Function: read_filenames*/
    /*Purpose: read text files containing all scene filenames this function will be called in the main read file function*/
    /*Return: a pointer to an array of chars containing the filenames*/
    /*Params: nothing*/
    
    FileNames *read_filenames(void);
    
    /*Function: read_files*/
    /*Purpose: To read the files containing vector information*/
    /*Return: A pointer to a vector list*/
    /*Params: Nothing*/
    
    ListNode *read_files(void); 
    
    #endif
    I'm getting loads of errors all of a sudden including:

    c:\documents and settings\administrator\my documents\programming\programming\programming practice\readfile.h(8) : error C2085: 'tagFileNames' : not in formal parameter list

    and then when I sometimes try and build it I get an error saying it cant be saved as its being used by another app and then the file deletes itself from the hard drive????

    Anyone got any ideas - I've never had this before?

    Thanks in advance

    Helen

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    181
    hai,

    Code:
    typedef struct tagFileNames{
    	char fileName[20];
    }tagFileNames;
    u dont require to delcare tagFilenames twice. as u are using typedef it. hope this is what u are expecting
    Code:
    typedef struct{
    	char fileName[20];
    }tagFileNames;
    s.s.harish

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    11
    Quote Originally Posted by thedoofus
    Hi -

    I'm having the most random problem.

    I've got a header file readfile.h and in it is a structure I've created

    Code:
    #ifndef _READFILE_H_
    #define _READFILE_H_
    #include "vectorlist.h"
    
    
    typedef struct tagFileNames{
    	char fileName[20];
    }tagFileNames;
    and then when I sometimes try and build it I get an error saying it cant be saved as its being used by another app and then the file deletes itself from the hard drive????
    The first problem is that you are using the same identifier twice. Try redoing your Structure like this...
    Code:
    typedef struct tagFileNames{
                    char FileName[20]
                   } FileNames, *pFileNames;
    This gives you a type "FileNames" (the structure) and a type "pFileNames" (a pointer to the structure) you can use in your code.

    The second problem (esp on Windows) is probably the result of the file being opened in two places... I'd guess you've somehow ended up with the editor/ide for your programming opened twice with the same file. (Next time you get this error check your task list, you'll probably see it listed twice)

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,823
    > u dont require to delcare tagFilenames twice
    But it isn't illegal to do that, just a little unusual.

    The real problem is more likely to be something like a missing ; in the previous included file
    Namely
    #include "vectorlist.h"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    24
    That worked perfectly - had a missing ; just like you said.

    the tagFileNames isn't normally in there but I'd changed it in a desperate attempt to find out the problem

    Cheers everyone for your help.

    Helen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random to int?
    By psyadam in forum C# Programming
    Replies: 7
    Last Post: 07-22-2008, 09:09 PM
  2. Lesson #3 - Math
    By oval in forum C# Programming
    Replies: 2
    Last Post: 04-27-2006, 09:16 AM
  3. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 05:51 PM
  4. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 03:40 PM
  5. Best way to generate a random double?
    By The V. in forum C Programming
    Replies: 3
    Last Post: 10-16-2001, 05:11 PM

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