Hi every one here,
I am a university student of computer engeneering...altough still in the very begining i've got great interest making head or tails of programming stuff.
I am new to c programming ..it's around months from the time we started learing & coding with that, We have entered the stuff of c++ recently.
As the peroject of our term we have been told to code a few commands of "shell" in visual c++, without using system functions or unstandard libraries.
As for this, it requires that i learne well how to work with directories & stuff. i realized that direct.h provides us with some functions useful in the case....do u think it is unstandard to use this library?
...if still yes, then it doesnt provide me with anything to access the subfolders of a folder in order to code "dir" in win or "shell" in linux...
1-What recomandation do u think will help me deal with directories better? ..any standard unsystematic library u know ??

2- How about accessing subfolders of a directory to show them in a list as does the command "ls" or "dir" ?

3- how about clearing the screen ??...without the use of systm("cls"), how do u thinki can write in windows?

Thanx in advace dear experts !
Mahsa Mohammadi

Does this have to be cross platform? You are kind of confusing me when you say
3- how about clearing the screen ??...without the use of systm("cls"), how do u thinki can write in windows?

Gives the impression its just for windows. But other things say linux too...

oh sorry..i know i confusingly mentioned my question.
Yes it should be multi platform bECAUSE we must not use any of system functions, if we dont use them then the program automaticly becomes multi platform.
The program is to be developed & coded in windows (i work better in windows), ....atthe end the project would be like this:
A standard c consule must work just like a command prompt in win !
for example , typing "cls" must lead to clearing the consule , & typing "dir" must as well lead to showing a list of the current directories, typing "cd" must change the current direcories & so on ( Ten commands are gonna be developed)
i have written cd, chdir,del & exit. but in all of them i got use of direct.h providing me with _chdrive() to change the current drive, _chdir() to change the current directory & stuff like that....The prob i've got is that firstly i donno if the use of direct.h is standard & that whether it is one of the system libraries that i'm not allowed to use. ( i dont have the possibility of asking the teachers about that, all must be learened by our own searches)......
so i wanna be given two answers:
-whether using direct.h is ok , ..so if yes i donno how to develop "dir" & "cls"..the library doesnt provide me with those.
or else, it cant use it ...if so how should i deal with these things , using very very common functions,...then i'll need help to see how these system functions are basicly developed so that i write one myself !

Hoping i'll got somewhere finally !
tanx in advance.
:)

try googling because it will answer many of the questions you have. The solutions are not simple, so you will need basic understanding of C and/or C++ languages.

windows console functions

clear windows console screen

This one I wrote to show how to use FindFirst() and FindNext() win32 api functions. Its not exactly what you want but should give you a start to write your own dir command.

list directories

You cannot write this to be multi platform. As Salem said you will need to use the windows console functions to deal with things such as system("cls") however these libraries are non standard to all OS's only windows. Also you would need to use the windows.h header for effective directory operations. But since this is all windows based development it is not cross platform.

As far as I am aware there is no cross platform method (using standard libraries) that will allow you to produce something like this.

Chris

I think what Freaky means is there is no one set of c or c++ functions that will do everything you want for all platforms.

To make a program cross platform you have to write all the code for all platforms then use conditional precompile directives. For example, if you want windows and unix

#ifdef _WIN32
// code here for windows platform
#elifdef _UNIX
// code here for unix platform
#elifdef _SOMEOTHER PLATFORM
// code here for the other platform
#endif

Of course that make the source code quite large, if you want just one source file to do everything that is the only way it can be done. Then you have to compile the program on each platform you want to support and define the appropriate symbol in the compiler you use.

Thank u , indeed very much.
Hopefully i'm getting somewhere to realize what the whole story is about.
Today,after a lot of effforts Of bombarding my professors & their assistances i got this reply:
** You are allowed to use some functions with these condition***
**It shouldnt be --- int system( char* command)---
**It must not enter the MFC of the program.( should figure out more about the expression 'MFC' )
**You are allowed to use functions opening a drive & directory (This one was of total relief to me, i though i must handle then myslef, that looked far from even imagination :D )
....***
So in conclusion i realized i can use these things:
_chdrive(int ) //changing the current drive .
_chdir( char* address) // changing current directories.
FILE* fopen ( char* address )....

And such fucntions following the above charactristics .
With the help of these my "cd", "chdir", "exit" ( veery easy indeed, only one line [exit(0)] :D ) are healthy & ready to use,
all that remains is to figure more about "cls","dir" !
God willingly i'll descover them under ur helps too !

tANKS VERYYYYY mUCh
Mahsa
18 years
School of Sharif University of Technology

Thank u verrrryyy much, for ur replies, ur links, & ur helps.
(take a a look at my reply to Freak)
:)

It 's becomming clear what exactly i should do !
thanks a great deal.

>>all that remains is to figure more about "cls","dir"
We already told you how to do those.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.