iostream??

This is a discussion on iostream?? within the Linux Programming forums, part of the Platform Specific Boards category; Can I run a C++ program that includes <iostream.h> within unix??...

  1. #1
    BMF
    BMF is offline
    Registered User
    Join Date
    Mar 2005
    Posts
    4

    iostream??

    Can I run a C++ program that includes <iostream.h> within unix??

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,702
    Only if it's supported, but why would you? Use the standard <iostream> header instead.

    gg

  3. #3
    BMF
    BMF is offline
    Registered User
    Join Date
    Mar 2005
    Posts
    4
    mmm..
    Soooorry I mean linux.. sorry I am beginner..
    I need it because I wrote my code and used new keyword which is a C++ feature but I am not sure if I can compile & run it in linux..
    I don't have unix installed on my PC so I can't test it now.. I test it in Turbo C only..

    This is my code--> can I run it on linux??
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <iostream.h>
    
    
    typedef struct info* infoptr;
    struct info{
    	char permission[11];
    	char digit[5];
    	char owner[20];
    	char group[20];
    	long int size;
    	char mtime[15];
    	char fname[20];
    	infoptr next;
    	};
    
    void main(){
    	FILE* fp;
    	infoptr head, cur;
    	int i, dcount=0, fcount=0;
    	long int fsize=0, dsize=0, size=0;
    
    	system( "ls -l>info.txt" );
    	fp = fopen("info.txt","r");
    	if( fp==NULL )
    	head = NULL;
    	else{
    	infoptr temp_info1, temp_info2, cur;
    	temp_info1 = new info;
    	head = temp_info1;
    	 fscanf( fp, "%s", temp_info1->permission );
    	 fscanf( fp, "%s", temp_info1->digit );
    	 fscanf( fp, "%s", temp_info1->owner );
    	 fscanf( fp, "%s", temp_info1->group );
    	 fscanf( fp, "%ld", &temp_info1->size );
    	 fscanf( fp, "%s", temp_info1->mtime );
    	 fscanf( fp, "%s", temp_info1->fname );
    	 temp_info1->next = NULL;
    	  while( !feof(fp) ){
    	 temp_info2 = new info;
    	 temp_info1->next = temp_info2;
    	 temp_info1=temp_info2;
    	 fscanf( fp, "%s", temp_info1->permission );
    	 fscanf( fp, "%s", temp_info1->digit );
    	 fscanf( fp, "%s", temp_info1->owner );
    	 fscanf( fp, "%s", temp_info1->group );
    	 fscanf( fp, "%ld", &temp_info1->size );
    	 fscanf( fp, "%s", temp_info1->mtime );
    	 fscanf( fp, "%s", temp_info1->fname );
    	 }
    	 temp_info1->next = NULL;
    	} // end if
    
    	printf( "List of my files:\n" );
    	for( cur=head; cur!=NULL; cur=cur->next ){
    		if( strchr(cur->fname, '.')!=NULL ){  //???
    		printf( "\t%s\n", cur->fname );
    		fcount++;
    		fsize+= cur->size;}
    	}
    	printf( "\nTotal files: %d\n", fcount );
    	printf( "Total files size: %ld bytes\n", fsize );
    
    
    	printf( "\nList of my Directories:\n" );
    	for( cur=head; cur!=NULL; cur=cur->next ){
    		if( strchr(cur->fname, '.')==NULL ){  //???
    		printf( "\t%s\n", cur->fname );
    		dcount++;
    		dsize+= cur->size;}
    	}
    	printf( "\nTotal directories: %d\n", dcount );
    	printf( "Total directories size: %ld bytes\n", dsize );
    
    	size = fsize+dsize;
    	printf( "Total size of all files & directories: %ld bytes\n", size );  
    }//end main
    Last edited by BMF; 03-20-2005 at 01:35 PM.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    first of all, don't include <iostream.h>. you don't need to include it. if you did, you would include <iostream> not iostream.h. you don;'t need <string.h> or <string> either. it looks like it should compile.

    if you were using c++, you would compile with g++. for c programs you compile with gcc
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drieving from iostream
    By Thantos in forum C++ Programming
    Replies: 8
    Last Post: 06-23-2004, 05:57 PM
  2. iostream & hex?
    By dmlx90 in forum C++ Programming
    Replies: 0
    Last Post: 05-23-2002, 12:51 AM
  3. DJGPP Doesn't include IOSTREAM!!!!!!!!!!!
    By Frenchfry164 in forum Game Programming
    Replies: 12
    Last Post: 10-27-2001, 01:27 PM
  4. << in iostream
    By badman in forum C++ Programming
    Replies: 8
    Last Post: 10-18-2001, 11:19 PM
  5. Is there a C iostream?
    By Khisanth in forum C Programming
    Replies: 1
    Last Post: 09-05-2001, 01:34 AM

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