473,394 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Need help in C++ command line operations

18
Hi all,

I have a c++ programme that intakes a binary file and performs various operations on it. I am not gonna get in to the details of the operations, currently i specify the order in which the operations take place by calling different functions the way i write the main function. My question is -- Is there a way that a user can call different functions from this application from the command line.
For example.

say i have 3 functions namely F1 , F2, F3.

now fromthe command line once i have started the application can i call
F2 ----(F2 does something and produces result) and then I call
F3 and similarly the other functions in the order I like.

Thanks for all the help in advance. If my question is not clear enough plz let me know.

Ammar.
Mar 23 '07 #1
2 1310
DeMan
1,806 1GB
I don't know whether this is quite what you mean, but you can specify commandline paramters when you run your program eg:

Expand|Select|Wrap|Line Numbers
  1. a.out F1
  2.  
This can be retreived in main :

Expand|Select|Wrap|Line Numbers
  1. int main(int argc, char argv[])
  2. {
  3.   if(argc > 1) // The first element is this program
  4.   {
  5.     for(int i=1; i< argc; i++) 
  6.     {
  7.       if((strcmp(argv[i], "F1")==0)
  8.       {
  9.          printf("Whohoo");
  10.       }
  11.     }
  12.   }
  13. }
  14.  
Obviously you can add other checks (you might like to make a function to do it).

Otherwise (if you want these commands to be entered WHILE the programming is running), (cin) input will appear to come from teh commandline (though you won't be able to do anything else from the commandline at the time)

Hope this helpes
Mar 23 '07 #2
AmmarN
18
Thank you for your reply.

You are right i actually would like to call the functions while the programme is running and i understand that i wont be able to do anything else at the command line while the prograame is running. Its an application so i wanna run the programme first and then call different functions while the programme is running such as:

a.out Open (filename)
a.out CallF1 (x,y,z)
(after F1 produces its result e.g "Woohoohoo" then
a.out CallF2 (a,b,c)
.
.
.
and Finally

a.out Quit.

meaning call different functions from the command line with the parameters.
Any help with the structure of the main function to acheive the above will be highly appreciated.
Mar 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: gorda | last post by:
Hello, Using sed or awk, I can quickly parse and perform operations on the command line itself as in: cat file | sed 's/cat/dog' cat file | awk ' /cat/ {print "found the cat"} ' How can i...
1
by: TEK | last post by:
Hello I'm wondering if anyone out there might give some input/suggestions/viewpoints around the Command pattern. In my case, the number one priority for using the pattern is undo support. Some...
5
by: Mr. X | last post by:
Hello, Let me begin by saying that I am a strong advocate of science, math and engineering students learning to program... just a skill that they need to experience even if they go another path....
2
by: trixie | last post by:
Using WinXP and Python24 on generic desktop. Being used to linux and command line operations I cannot make Windows accept the 'python myprog.py' command. Any help appreciated. Bob
3
by: stefaan.lhermitte | last post by:
Dear MySQL-ians, I perform a SELECT on my database, but it takes over a minute for every run. I have to run it over 10000 times (with different values in the WHERE), so it takes way too long. A...
15
by: AmmarN | last post by:
Hi all, I have a c++ programme that intakes a binary file and performs various operations on it. I am not gonna get in to the details of the operations, currently i specify the order in which the...
2
by: kya2 | last post by:
I am not able to create following store procedure. CREATE PROCEDURE DBSAMBA.InsertDeleteBatch(OUT norows INT ) RESULT SETS 1 LANGUAGE SQL BEGIN part1 DECLARE TOTAL_LEFT INT DEFAULT 0; ...
2
by: Peng Yu | last post by:
Hi, Perl has a command line help perldoc. I'm wondering if python has a similar help command. Thanks, Peng
3
by: Eric_Dexter | last post by:
I am trying to take some data in file that looks like this command colnum_1 columnum_2 and look for the command and then cange the value in the collum(word) number indicated. I am under...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.