Can I run a C++ program that includes <iostream.h> within unix??
Printable View
Can I run a C++ program that includes <iostream.h> within unix??
Only if it's supported, but why would you? Use the standard <iostream> header instead.
gg
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
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