include file

This is a discussion on include file within the C++ Programming forums, part of the General Programming Boards category; this is the contenent of <cryptio.h> when i include it in any main is declare errors !!! please can you ...

  1. #1
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159

    Unhappy include file

    this is the contenent of <cryptio.h>
    when i include it in any main is declare errors !!!
    please can you help me

    Code:
    #include <conio.h>
    #include "stdio.h"
    #include "string.h"
    #include "stdlib.h"
    #include "fstream.h"
    
    /************************* codation d'u caractere ****************************************/
    char codec(char g)
    
    {
    
    int c;
    
    c=(int)g;
    if(c>=254){return(g);}
    else
    {
    c++;
    g=(char)c;
    return(g);
    }
    
    }
    /**************************** fin codation d'un caractere ****************************/
    /*********************************** decodation d'un caractere **************************/
    char decode(char g)
    
    {
    
    int c; 
    c=(int)g;
    if(c>=254)
    {return(g);}
    else
    {
    c--;
    g=(int)c;
    return(g);
    }
    }
    /********************************* fin decodation d'un caracterer ************************/
    
    
    
    /**************************** decryptage d'un fichier ***************************/
    
    void decrypte(fstream &T,char name[]) //pass the file stream to the function 
    
    {  
    
    	
    	// the method to read a file , that I ....
    	char chy,chn;
    	fstream file(name,ios::in|ios::out);
    	
    	while(!T.eof())
    	{
    	
    	T.get(chy);
    	if(chy==NULL){break;}
    	chn=decode(chy);
    	
    	file<<chn;
    	
    	}
    
    file.close();
    
    }
    /********************** decryptage d'un fichier ****************************//********************************* cryptage d'un fichier *****************/
    void crypte(fstream &T,char name[])   //pass the file stream to the function 
    { 
    	
    	// the method to read a file , that I ....
    	char chy,chn;
    	fstream file(name,ios::in|ios::out);
    	
    	while(!T.eof())
    	{
    	T.get(chy);
    	chn=codec(chy);
    	file<<chn;
    	
    	}
    file.close();
    
    }
    /******************************* fin decryptage ********************************/

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    Paste your error messages as well

  3. #3
    #include<xErath.h> xErath's Avatar
    Join Date
    Jun 2004
    Posts
    722
    Quote Originally Posted by enjoy
    this is the contenent of <cryptio.h>
    when i include it in any main is declare errors !!!
    You're DEFINING (not declaring) functions, and you don't had the proper pre-compiler directives to prevent re-evaluation of the header. It should be like this
    Code:
    #ifndef _CRYPTIO_H_
    #define _CRYPTIO_H_
    /***
    Header content here
    ***/
    #endif //_CRYPTIO_H_
    Also, place the functions DEFINITION in a *.cpp, and in the header place only declarations like
    Code:
    char codec(char g);
    char decode(char g);
    void decrypte(fstream &T,char name[]);
    void crypte(fstream &T,char name[]);
    That and the precompiler directives.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. Header file include order
    By cunnus88 in forum C++ Programming
    Replies: 6
    Last Post: 05-17-2006, 03:22 PM
  5. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM

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