473,395 Members | 1,454 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,395 software developers and data experts.

Help With Simple Program...

18
Hello everyone,

I have a problem with a rather simple thing. I have to make the code of a program. The program is already made, I have the executable and all, the only thing I need is the source code(in C). The problem is, I don't really know how to do it.

All the program does is tell you when a light is on or off. It has four switches and a battery. If only one switch is on, then the light is off. If any combination of the four switches(if two are on), then the light is ON. Can somebody help me taking out the code from the executable?

To make the program work, you have to open it in MSDOS and type the name of the program(demoTL01) and then the number of the switch to tell it's on... so for example:

demoTL01 1

Tells the program that only the first switch is on, making the light off.

demoTL01 1 2

Tells the program that the first two switch are on, making the light on.

Etc..

Here it is(if you want it, scan it first) and please right click and save as it:

http://www.angelfire.com/wrestling3/roleplays0/demoTL01.exe

THANKS!!!
Jan 24 '07 #1
46 2272
RedSon
5,000 Expert 4TB
Do you have a question about a particular section in your code? You should post the source code for the executible or what your assignment is and not ask us to download an .exe. Have you tried to solve this yet? What have you accomplished so far? If you are better prepared and have tried to solve your problem first then it is more likely you will get help from someone later.
Jan 24 '07 #2
Narc0
18
Do you have a question about a particular section in your code? You should post the source code for the executible or what your assignment is and not ask us to download an .exe. Have you tried to solve this yet? What have you accomplished so far? If you are better prepared and have tried to solve your problem first then it is more likely you will get help from someone later.
That's what I need: the source code from that executable or a way to replicate that same thing. The problem is I don't even know where to start. So I need help from you guys.

Thanks!
Jan 24 '07 #3
nickyeng
254 100+
That's what I need: the source code from that executable or a way to replicate that same thing. The problem is I don't even know where to start. So I need help from you guys.

Thanks!
If there is a way to form an executable file back into source code, I would have done it but yet it dont exist.

correct me if i'm wrong.
If somehow can make an executable file back into source code, please tell me.
:-)

from
Nick
Jan 24 '07 #4
Motoma
3,237 Expert 2GB
In order for us to be helpful, you need to be helpful as well.
In clear English, describe what you are trying to accomplish, as well as what steps you have taken to do so. Delineate the problems you have encountered, as well as your ideas as to what the cause of the problems are. Include source code, with as much commenting as you are able to provide.
Jan 24 '07 #5
Narc0
18
Again, I haven't even started because I don't know how to.

What I want is someone to reproduce the thing in that .exe. Exactly the same thing.
Jan 24 '07 #6
Motoma
3,237 Expert 2GB
Again, I haven't even started because I don't know how to.

What I want is someone to reproduce the thing in that .exe. Exactly the same thing.
Okay, so what, exactly, does this program do? You mention switches, are these switches the arguments you pass to the program on the command line, or are they physical switches plugged into one of the various ports of the computer? You mention that it tells you if a light is on or off, where is this light? And how does it 'tell' you?
Jan 24 '07 #7
DeMan
1,806 1GB
Some tips (I shall assume you know at least the C Basics):

in the main method of your program (you know the one called main) you are passed an array o command line arguments:

int main (char args[]) //or however you want to call them
you need to parse args to tell which switches are selected.

You say when (any?) two are selected, the light is on, consider what the behaviour is for three, or four.

I am assuming (because angelfire quite wisely does not allow me to download executable files) that the output simply says "Light is ON" in whcih case a simple printf will do the trick.

If you do not understand what the main method even is, I would suggest you got to Banfa's tutorial http://www.thescripts.com/forum/thread570739.html
Jan 24 '07 #8
Narc0
18
Guys, if you download the .exe(right click and save as), and follow the instructions on my first post, you'll know what the program does. And all I want is a code that does exactly that, nothing more.

THANKS!
Jan 24 '07 #9
Motoma
3,237 Expert 2GB
Guys, if you download the .exe(right click and save as), and follow the instructions on my first post, you'll know what the program does. And all I want is a code that does exactly that, nothing more.

THANKS!
I'm sorry, I tried downloading the file as the first step to helping you, but I came to a page which states:

Angelfire does not allow downloading
of certain file types to protect
visitors from computer viruses.
If you could give us a written description, including the things I asked for in the my previous post, I will do what I can to help.
Jan 24 '07 #10
Narc0
18
Did you try right clicking it and saving as? That's what I did and it works. If not, then it's on geocities too... right click and save as...

http://yoyirod.googlepages.com/demoTL01.exe

THANKS!
Jan 24 '07 #11
Motoma
3,237 Expert 2GB
Did you try right clicking it and saving as? That's what I did and it works. If not, then it's on geocities too... right click and save as...

http://yoyirod.googlepages.com/demoTL01.exe

THANKS!
Psuedo-Code, guarenteed not to work properly:
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. int main(int argc, char* argv[])
  3. {
  4.   int num = 0;
  5.   for(int i = 1; i <= argc; i++)
  6.     if(argv[i] == '1' || argv[i] == '2' || argv[i] == '3' || argv[i] == '4')
  7.       num++;
  8.     else
  9.       printf("%s?!?  That isn't one of the switches!", argv[i]);
  10.   if(num > 1) printf("%s","Let there be light.");
  11.   else printf("%s","Let there be night.");
  12.   return 0;
  13. }
  14.  
This was whipped up in a matter of seconds, and still requires some more refining: for instance, if the user specifies that switch 1 is on twice (i.e. Light.exe 1 1 1 1 1) it will register as being on.
Jan 25 '07 #12
Narc0
18
I compiled it and there is a problem in the "for" line. It says for declaration used outside C99 Mode. Any more help or finishing that code would be very helpful.

THANKS!
Jan 25 '07 #13
Motoma
3,237 Expert 2GB
I compiled it and there is a problem in the "for" line. It says for declaration used outside C99 Mode. Any more help or finishing that code would be very helpful.

THANKS!
It's only pseudo-code, it wasn't made to compile...I wrote it to show you the basic flow of the program, as well as how to utilize the arguments from the command line.

The error you are getting sounds like a compiler error...What compiler are you using? Are you working with an IDE as well? The more information you give me, the more I can help you out.
Jan 25 '07 #14
Narc0
18
Bloodshed's Dev-C++. I need a source code because I don't know how to code it.
Jan 25 '07 #15
Motoma
3,237 Expert 2GB
You may have to declare the integer i outside the for loop:
Expand|Select|Wrap|Line Numbers
  1. int i;
  2. for(i = 0; i...
  3.  
Jan 25 '07 #16
Motoma
3,237 Expert 2GB
I need a source code because I don't know how to code it.
Allow me to make the following suggestion:
Read the C/C++ tutorials by Banfa and Gannon11.
Not only are these great pieces of writing, but they cover exactly the type of program you are trying to write.
Jan 25 '07 #17
Banfa
9,065 Expert Mod 8TB
Bloodshed's Dev-C++. I need a source code because I don't know how to code it.
How much of the C/C++ language do you know?

Can you write a program that prints "Hello World"?
Jan 25 '07 #18
Narc0
18
I tried something but I want to do it differently. Here's the code:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
int Switch1=0;
int Switch2=0;
int Switch3=0;
int Switch4=0;
printf("To turn a switch on, press 1, otherwise press 0\n");

printf("Switch1=");
scanf("%d",&Switch1);

printf("Switch2=");
scanf("%d",&Switch2);

printf("Switch3=");
scanf("%d",&Switch3);

printf("Switch4=");
scanf("%d",&Switch4);


if (Switch1>1 && (Switch2>1||Switch3>1||Switch4>1) ||(Switch1<0 && (Switch2<0||Switch3<0||Switch4<0)))

printf("ERROR: 'Numbers have to be 1 and 0'\n");


if(Switch1==1 && (Switch2==1||Switch3==1||Switch4==1))

printf("\nLight is on\n");

else

printf("\nLight is off\n");
return 0;
}


Is there another way I could do the same...?
Jan 25 '07 #19
Motoma
3,237 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.   int Switch[4], i;
  7.   for(i = 1; i <= argc; i++)
  8.     if(argv[i] == '1' || argv[i] == '2' || argv[i] == '3' || argv[i] == '4')
  9.       Switch[atoi(argv[i]) - 1] = 1;
  10.     else
  11.       printf("%s?!?  That isn't one of the switches!", argv[i]);
  12.   if(Switch[0] + Switch[1]+Switch[2]+Switch[3] > 1) printf("%s","Let there be light.");
  13.   else printf("%s","Let there be night.");
  14.   return 0;
  15. }
  16.  
Jan 25 '07 #20
RedSon
5,000 Expert 4TB
Holy Mackerel! I am in actual physical pain from reading this thread. You guys have the patience of a saint, I bailed out a long time ago.
Jan 25 '07 #21
Narc0
18
Thanks RedSon for being so helpfull. Remember, you started like me.

Anyways, I compiled that last code and I got an error. Line8 "[Warning] comparison between pointer and integer"
Jan 25 '07 #22
RedSon
5,000 Expert 4TB
Thanks RedSon for being so helpfull. Remember, you started like me.

Anyways, I compiled that last code and I got an error. Line8 "[Warning] comparison between pointer and integer"
While it is true that my skill levels starting out were like yours I can assure that I never started like you. I respected the knowledge and lessons that my instructors were trying to impart on me and I never cut-and-pasted a homework question to a forum and expected someone else to do it for me. Before I post a question I always do an extensive google search on both the web and google groups. After that I search the forum in which I am posting to see if another person has posted something similar.

I also, never ask anyone to download anything from any website espically something that is an executible or in binary. Do you know how easy it is to write a virus? One that is not in any catalog nor can be detected easily by virus scanning heuristics. Next time do a little bit of leg work on your own and then show us that you have done the proper amount of work on your own by saying what you tried, how it failed, and why you think it doesn't work.

Furthermore you should be kissing the gound that
Jan 25 '07 #23
DeMan
1,806 1GB
And patient too...
Jan 25 '07 #24
RedSon
5,000 Expert 4TB
While it is true that my skill levels starting out were like yours I can assure that I never started like you. I respected the knowledge and lessons that my instructors were trying to impart on me and I never cut-and-pasted a homework question to a forum and expected someone else to do it for me. Before I post a question I always do an extensive google search on both the web and google groups. After that I search the forum in which I am posting to see if another person has posted something similar.

I also, never ask anyone to download anything from any website espically something that is an executible or in binary. Do you know how easy it is to write a virus? One that is not in any catalog nor can be detected easily by virus scanning heuristics. Next time do a little bit of leg work on your own and then show us that you have done the proper amount of work on your own by saying what you tried, how it failed, and why you think it doesn't work.

Furthermore you should be kissing the gound that
Damn timeout.

kissing the ground that Motoma walks on for sticking with you for this long. If you want to be a programmer you are going to show us that you are willing to put in just as much time and effort as we do helping you.
Jan 25 '07 #25
RedSon
5,000 Expert 4TB
And patient too...
Huh? What are you refering to here?
Jan 25 '07 #26
Narc0
18
I never said I am not grateful for the help, the only thing I disliked was your comment. Not necessary.

Anyways, any other help?

THANKS!
Jan 26 '07 #27
Motoma
3,237 Expert 2GB
Thanks RedSon for being so helpfull. Remember, you started like me.

Anyways, I compiled that last code and I got an error. Line8 "[Warning] comparison between pointer and integer"
My apologies, we have come to the limits of my knowledge. Sorry I couldn't help you more.
If someone else, more knowledgable than I could come in and correct my code, I am sure both Narc0 and I would be more than grateful.
Jan 26 '07 #28
Banfa
9,065 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.   int Switch[4], i;
  7.   for(i = 1; i <= argc; i++)
  8. Problem here discussed below */
  9.     if(argv[i] == '1' || argv[i] == '2' || argv[i] == '3' || argv[i] == '4')
  10.       Switch[atoi(argv[i]) - 1] = 1;
  11.     else
  12.       printf("%s?!?  That isn't one of the switches!", argv[i]);
  13.   if(Switch[0] + Switch[1]+Switch[2]+Switch[3] > 1) printf("%s","Let there be light.");
  14.   else printf("%s","Let there be night.");
  15.   return 0;
  16. }
  17.  
The problem is that argv is a pointer to and array of pointers char *argv[] or equivilently char **argv. So argv[i] has type char *, it is a pointer to an array of characters (and in this case these arrays of characters are NULL terminated strings).

I guess you are trying to test the first character in the string, for instance
Expand|Select|Wrap|Line Numbers
  1. char hw[] = "Hello World";
  2.  
  3. if (hw[0] == 'H')
  4. {
  5.     printf("Hello is capitalised\n");
  6. }
since you are comparing to '1' so you need an extra level of dereferencing

Expand|Select|Wrap|Line Numbers
  1.     if(argv[i][0] == '1' || argv[i][0] == '2' || argv[i][0] == '3' || argv[i][0] == '4')
  2.  
note however this will not handle a command line of this nature

ProgramName 1234

because 1234 with come through as a single entry in the argv array.
Jan 26 '07 #29
Motoma
3,237 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.   int Switch[4], i;
  7.   for(i = 1; i <= argc; i++)
  8. Problem here discussed below */
  9.     if(argv[i] == '1' || argv[i] == '2' || argv[i] == '3' || argv[i] == '4')
  10.       Switch[atoi(argv[i]) - 1] = 1;
  11.     else
  12.       printf("%s?!?  That isn't one of the switches!", argv[i]);
  13.   if(Switch[0] + Switch[1]+Switch[2]+Switch[3] > 1) printf("%s","Let there be light.");
  14.   else printf("%s","Let there be night.");
  15.   return 0;
  16. }
  17.  
The problem is that argv is a pointer to and array of pointers char *argv[] or equivilently char **argv. So argv[i] has type char *, it is a pointer to an array of characters (and in this case these arrays of characters are NULL terminated strings).

I guess you are trying to test the first character in the string, for instance
Expand|Select|Wrap|Line Numbers
  1. char hw[] = "Hello World";
  2.  
  3. if (hw[0] == 'H')
  4. {
  5.     printf("Hello is capitalised\n");
  6. }
since you are comparing to '1' so you need an extra level of dereferencing

Expand|Select|Wrap|Line Numbers
  1.     if(argv[i][0] == '1' || argv[i][0] == '2' || argv[i][0] == '3' || argv[i][0] == '4')
  2.  
note however this will not handle a command line of this nature

ProgramName 1234

because 1234 with come through as a single entry in the argv array.

Banfa to the rescue!
Some yummy gooey tasty code to follow:
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.   int Switch[4] = {0,0,0,0}, i;
  7.   for(i = 1; i < argc; i++)
  8.     if((argv[i][0] == '1'  && argv[i][1] == '\0') ||
  9.         (argv[i][0] == '2'  && argv[i][1] == '\0') ||
  10.         (argv[i][0] == '3'  && argv[i][1] == '\0') ||
  11.         (argv[i][0] == '4'  && argv[i][1] == '\0'))
  12.       Switch[atoi(argv[i]) - 1] = 1;
  13.     else
  14.       printf("%s?!?  That isn't one of the switches!\n", argv[i]);
  15.   if(Switch[0]+Switch[1]+Switch[2]+Switch[3] > 1) printf("%s","Let there be light.\n");
  16.   else printf("%s","Let there be night.\n");
  17.   system("pause");
  18.   return 0;
  19. }
  20.  
Jan 26 '07 #30
Banfa
9,065 Expert Mod 8TB
You realise that you can re-write

Switch[atoi(argv[i]) - 1] = 1;

as

Switch[argv[i][0] - '1'] = 1;

which removes the call to silly olfd atoi and is slightly more efficient.
Jan 26 '07 #31
Motoma
3,237 Expert 2GB
You realise that you can re-write

Switch[atoi(argv[i]) - 1] = 1;

as

Switch[argv[i][0] - '1'] = 1;

which removes the call to silly olfd atoi and is slightly more efficient.
You learn something new every day...well, I do...
More so since I've been reading your posts!
Jan 26 '07 #32
Narc0
18
That does the work but there's still a problem.

There's a switch that is the main one. This switch MUST be on and any of the other ones to turn the light on. So that's the main switch. The program turns the light on with any combination of the switches, and the light can only turn on with this main switch and any of the other ones.

Also, when I put, for example, ProjectName 5, since that switch doesn't exist the program tells me that the switch doesn't exist. That's correct and that's what I want but it ALSO tells me that the light is on.

Any help?

THANKS!
Jan 26 '07 #33
Banfa
9,065 Expert Mod 8TB
That does the work but there's still a problem.

There's a switch that is the main one. This switch MUST be on and any of the other ones to turn the light on. So that's the main switch. The program turns the light on with any combination of the switches, and the light can only turn on with this main switch and any of the other ones.

Also, when I put, for example, ProjectName 5, since that switch doesn't exist the program tells me that the switch doesn't exist. That's correct and that's what I want but it ALSO tells me that the light is on.

Any help?

THANKS!
Motoma has provided you with more than enough help to finish this. How about you try and make this modification yourself and post back the code if you have trouble.

It is not a very hard modification as the provided code already reads all the switches for you and already determins the state of the light even if there are bad switches on the command line. So all you have to is alter the logic about how it works out if the light is on or off.


It is time for you to read, understand and modify what has already been provided yourself rather than just keep posting back here with apparently no effort on your part.

The if you modify the code but have trouble getting the modification to work you should post back here.
Jan 26 '07 #34
Narc0
18
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.   int Switch[4] = {0,0,0,0}, i;
  7.   for(i = 1; i < argc; i++)
  8.     if((argv[i][0] == '1'  && argv[i][1] == '\0') ||
  9.         (argv[i][0] == '2'  && argv[i][1] == '\0') ||
  10.         (argv[i][0] == '3'  && argv[i][1] == '\0') ||
  11.         (argv[i][0] == '4'  && argv[i][1] == '\0'))
  12.       Switch[argv[i][0] - '1'] = 1;
  13.     else
  14.       printf("%s?!?  This is not a switch!\n", argv[i]);
  15.  
  16.   if(Switch[0]==1 && (Switch[1]==1||Switch[2]==1||Switch[3]==1))
  17.   printf("%s","Light is on.\n");
  18.  
  19.  
  20.   else 
  21.        printf("%s","Light is off.\n");
  22.   return 0;
  23. }
  24.  



I worked out the logic and now the program knows that switch 1 is the main one and without it the light will never turn on. But I have a problem. When I input a number greater than 4, it tells that that isn't a switch and that's perfect but it also tells me that the light is off. I'm stuck in making that part right.

THANKS!

Edit: I also would want another way to write this but with the same results:

if(Switch[0]==1 && (Switch[1]==1||Switch[2]==1||Switch[3]==1))
printf("%s","Light is on.\n");

Thanks!
Jan 26 '07 #35
Motoma
3,237 Expert 2GB
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
int Switch[4] = {0,0,0,0}, i;
for(i = 1; i < argc; i++)
if((argv[i][0] == '1' && argv[i][1] == '\0') ||
(argv[i][0] == '2' && argv[i][1] == '\0') ||
(argv[i][0] == '3' && argv[i][1] == '\0') ||
(argv[i][0] == '4' && argv[i][1] == '\0'))
Switch[argv[i][0] - '1'] = 1;
else
printf("%s?!? This is not a switch!\n", argv[i]);

if(Switch[0]==1 && (Switch[1]==1||Switch[2]==1||Switch[3]==1))
printf("%s","Light is on.\n");


else
printf("%s","Light is off.\n");
return 0;
}





I worked out the logic and now the program knows that switch 1 is the main one and without it the light will never turn on. But I have a problem. When I input a number greater than 4, it tells that that isn't a switch and that's perfect but it also tells me that the light is off. I'm stuck in making that part right.

THANKS!

Edit: I also would want another way to write this but with the same results:

if(Switch[0]==1 && (Switch[1]==1||Switch[2]==1||Switch[3]==1))
printf("%s","Light is on.\n");

Thanks!
Could you reply to this simply writing how you called this on the command line?
i.e:
Expand|Select|Wrap|Line Numbers
  1. MyProg.exe 1 3 44 2
Such that it displays the behavior you don't want.
Jan 26 '07 #36
Narc0
18
Edit:

Oh. I write

Whatever 5

and since 5 doesn't exist, it tells me that same thing BUT also that the light is off.
Jan 26 '07 #37
Banfa
9,065 Expert Mod 8TB
I worked out the logic and now the program knows that switch 1 is the main one and without it the light will never turn on. But I have a problem. When I input a number greater than 4, it tells that that isn't a switch and that's perfect but it also tells me that the light is off. I'm stuck in making that part right.
Are you saying that when you input

ProgramName 1 2 5

It tells you the light is off? because that is not how I am reading the code (perhaps I should try running it).

Edit: I also would want another way to write this but with the same results:

if(Switch[0]==1 && (Switch[1]==1||Switch[2]==1||Switch[3]==1))
printf("%s","Light is on.\n");
Exactly what about this line of code don't you like (or do you want to change). It seems slightly strange to reject a perfectly good line of code so it would be handy to know the reason before making another attempt.
Jan 26 '07 #38
Narc0
18
Also, if I input:

Projectname 1 2 5

It tells me the switch(5) doesn't exist but also tells me the light is on...

And I want another way simply because I am a curious person and want to know what other ways you could do the same.
Jan 26 '07 #39
Motoma
3,237 Expert 2GB
Edit:

Oh. I write

Whatever 5

and since 5 doesn't exist, it tells me that same thing BUT also that the light is off.
But the light IS off.

Perhaps what you want is this:

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. int Switch[4] = {0,0,0,0}, i;
  7. for(i = 1; i < argc; i++)
  8. if((argv[i][0] == '1' && argv[i][1] == '\0') ||
  9. (argv[i][0] == '2' && argv[i][1] == '\0') ||
  10. (argv[i][0] == '3' && argv[i][1] == '\0') ||
  11. (argv[i][0] == '4' && argv[i][1] == '\0'))
  12. Switch[argv[i][0] - '1'] = 1;
  13. else
  14. {
  15.   printf("%s?!? This is not a switch!\n", argv[i]);
  16.   return -1;
  17. }
  18.  
  19. if(Switch[0]==1 && (Switch[1]==1||Switch[2]==1||Switch[3]==1)) printf("%s","Light is on.\n");
  20. else printf("%s","Light is off.\n");
  21. return 0;
  22. }
  23.  
Jan 26 '07 #40
Banfa
9,065 Expert Mod 8TB
It tells me the switch(5) doesn't exist but also tells me the light is on...
Isn't that what you want?
And I want another way simply because I am a curious person and want to know what other ways you could do the same.
Equivalents of assuming Switch has been initialise to 0

if (Switch[0]==1 && (Switch[1]==1 || Switch[2]==1 || Switch[3]==1))

if (Switch[0] && (Switch[1] || Switch[2] || Switch[3]))

if (Switch[0]==1 & (Switch[1]==1 | Switch[2]==1 | Switch[3]==1))

if (Switch[0]==1 && (Switch[1]+Switch[2]+Switch[3]))

if (Switch[0]==1 && (Switch[1]+Switch[2]+Switch[3] > 0))

if (Switch[0]==1 && (Switch[1]+Switch[2]+Switch[3] >= 1))

if (Switch[0]*(Switch[1]+Switch[2]+Switch[3]) > 0)


That might not be all it's just an random selection, personally I think what you have is the best.
Jan 26 '07 #41
Narc0
18
Exactly!

Thanks man!

BTW, any other way to do the thing I put above?
Jan 26 '07 #42
Narc0
18
Isn't that what you want?
No, what I want is the program to tell me the switch doesn't exist and that's all.
Jan 26 '07 #43
Motoma
3,237 Expert 2GB
No, what I want is the program to tell me the switch doesn't exist and that's all.
See my last post.
Jan 26 '07 #44
Narc0
18
Yeah, I saw it.

Guys, millions thanks to all of you!
Jan 26 '07 #45
Narc0
18
I need another help. I think it's an easy one. Currently, when I run the program and don't assign anything, e.g: ProgramName, the program tells me the light is off. I want it to tell me something like "Huh?! You didn't turn any switch... How are you supposed to make it work" or something like that..

THANKS!
Jan 26 '07 #46
Banfa
9,065 Expert Mod 8TB
I need another help. I think it's an easy one. Currently, when I run the program and don't assign anything, e.g: ProgramName, the program tells me the light is off. I want it to tell me something like "Huh?! You didn't turn any switch... How are you supposed to make it work" or something like that..

THANKS!
Check the value of argc, it is number of command line parameters, since this includes the program name if argc is 1 then there were no switches on the command line.
Jan 27 '07 #47

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

Similar topics

31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
10
by: atlanta | last post by:
this is a simple C++ program to write. "Write a complete and functioning structured program that successfully compiles on Visual C++ 6, that uses two-dimensional array (5x5) that stores...
2
by: Vitali Gontsharuk | last post by:
Hi! I have a problem programming a simple client-server game, which is called pingpong ;-) The final program will first be started as a server (nr. 2) and then as a client. The client then...
2
by: Wally | last post by:
Is there a simple code for reading and transmitting infa red for the tv, vcr, dvd etc. I have a client who has limited/no use of her hands. I've purchased a tira-2 infa red receiver/transmitter...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
6
by: toch3 | last post by:
i am writing a c program that is basically an address book. the only header we are using is #include<stdio.hwe are to use a global array, loops, and pointers. we are to have a menu at the...
5
by: dav3 | last post by:
I am by no means an ultra slick programmer and my problem solving skills.. well they leave much to be desired. That being said I have been working on the following problem for the past few days and...
1
by: astrogirl77 | last post by:
I'm new to C++ and am hoping to find help with coding a simple C program, am wanting to obtain code and functioning exe's. I code in an old version of Visual Basic 4.0, I have a simple app that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.