[SOLVED] int main(int argc, char **argv[]) having trouble getting value out of array argv[ ] C programming.
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
@BW-userx I feel that you are spot on with a key core concept, which is to understand the logic behind what to do within your program, as opposed to worrying about how to write it as well as the choice of language.
I fully understand the concept of experimenting with code. You are asking the correct questions, for instance when you identify a questionable warning or error in compilation, it is a good idea to determine what the cause of it is. And per your original question, you were attempting to properly understand how passing arguments and pointers work within the language.
thanks.
I just figured C would be the easier then C++
though one might be able to use objects. I never put that to thought because I do not see any need to use an object in this project. Like I just told the other under your post before I got to it. I might even be able to use BASH Script to do this.
it is the logic that needs to be gotten in how to make it do it that needs to be accomplished. that too can be done side by side in learning the language one is using to do it.
but if I just jump into it like that. Then the order gets mixed up. because of the line of thought while trying to figure it out as I go is now almost random.
doing one thing then the thought oh I need to do this too, oops I should have done that first. now I got rethink everything then comes into play and I already have everything written out now I got a make changes. effect takes place.
thanks.
I just figured C would be the easier then C++
Actually, C++ can be easier than C, but it also is much more powerful and you can really screw up with it unless you really are good at object-oriented design.
Objective-C is simpler (i.e. no multiple inheritance, no friends, no operator overloading, no templates, etc.) but is mostly used just on Apple products, but the basic language is available for most platforms.
I'm not familiar with this game, maybe I'll try to download it to my iPhone, is it free?
Anyway, maybe someday you'll want to start programming your iPhone. It's pretty fun and if you get a good idea for an app you can make lots of money!
you never played yachee before?
What country are you from? is it banned there?
yes its free- the name is yachee deluxe by Rubicon that one as there is a bucket load of them. Just type in yachee and look for it.
99 cents a pop that does not even get you penny candy any more.
along with everything has already been done before. it is hard to get an original now days. it is all recaps of what was already done.
Actually, C++ can be easier than C, but it also is much more powerful and you can really screw up with it unless you really are good at object-oriented design.
Objective-C is simpler (i.e. no multiple inheritance, no friends, no operator overloading, no templates, etc.) but is mostly used just on Apple products, but the basic language is available for most platforms.
yeah over loading -- yeah over loading functions! I took C++ then when I was done they changed the standardization. Like two days after the classes where over.
I looked at it, and to me one now has to write more to get the same thing done, cout << is now std::cout << I never put time into it to relearn it. then fell away from programming. no real big loss.
I just find it fun to do and only use it when I need to. With Linux I find that a Bash script suffices.
I just thought I'd use C because that is a subset of C++ and it is basically the same without having to learn off of that syntax of C++ NAMESPACE declarations and what not's they now have within C++ or it will not work? I donno I left it behind.
between teaching ones self and going to a College and having someone show you, and guild you is a lot difference. and this is just for a self knowledge not really that big of a deal in the realm of things I am doing.
All I seem to be able to find are the "Yahtzee" dice games. Are you sure about the spelling?
yes that is the game I am talking about, it uses logic and reasoning some how. my other post on this to you tells you exactly what and who made it so you get the right one. you got to observe its behavior for a while. then perhaps you'll see what I am talking about.
you never played yachee before?
What country are you from? is it banned there?
yes its free- the name is yachee deluxe by Rubicon that one as there is a bucket load of them. Just type in yachee and look for it.
99 cents a pop that does not even get you penny candy any more.
along with everything has already been done before. it is hard to get an original now days. it is all recaps of what was already done.
I live in New York City in the good old USA! I must be doing something wrong:
But I am working on a blackjack program for the iPhone and right now it's just in text mode. I had another one and got pretty far, but I lost it due to a hard drive crash.
I was doing the logic and data processing, etc. at the same time. This time, I'm waiting to do the GUI stuff until I have it working on the command line as an alternate ViewController. Then I'll work on the GUI interface.
You just have to follow the rules of the game. In blackjack, there are several strategies, right now I only have the dealer strategy (which is easy) done.
ha New Yorkers. too many lights maybe? lol
us here too, I looked on my phone typed in yachee and went down the list until I found it, try using the name of the programmer or that makers name by who ever it was for a search word
Ok, I think I got it, but what does that have to do with programming?
what does what have to do with programming? yachee?
it is already a programmed game soooooo how they get that cpu to pick and know when to change its "mind" and get rid of what it already has to select something completely different?
But I am working on a blackjack program for the iPhone and right now it's just in text mode. I had another one and got pretty far, but I lost it due to a hard drive crash.
I was doing the logic and data processing, etc. at the same time. This time, I'm waiting to do the GUI stuff until I have it working on the command line as an alternate ViewController. Then I'll work on the GUI interface.
You just have to follow the rules of the game. In blackjack, there are several strategies, right now I only have the dealer strategy (which is easy) done.
yeah but I am working with a dry board. my brain
I have not put to thought the strategies yet. nor looked them up even. Just starting the how to get input then go to next step keeping it in a loop so the game keeps running -
roll
pick numbers
store numbers
roll again
pick numbers
store numbers
ask question here and there within it as well
ect
then display everything in a nice fashion.
It is not so much to get it to decide what to pick But when to change its mind when it has a good "hand"
Yachee has more to calculate then five cards. just saying.
with GUI what are you using?
that too may require being an artist if you got a draw the pictures to be used. then put them in an array maybe.
blackjack is 21 so yeah that is an easy strategie, if 17 and above and not over 21 hold. else hit. else bust.
Code:
if ( num >= 17 )
hold
else
hit
if ( num > 21 )
bust
if ( num == 21 )
win
that too may require being an artist if you got a draw the pictures to be used. then put them in an array maybe.
blackjack is 21 so yeah that is an easy strategie, if 17 and above if not over 21 hold. else hit.
I'll be using the built-in Cocoa GUI for the iPhone. Maybe the slightly different one for an OS X version.
That's the dealer strategy, but player strategies are more complex. They depend on what the dealer has up (if they have a weak card up like 5 or 6, you might want to stand on 14 for example hoping the dealer will bust). Plus the player can do things the dealer can't like double-down and split. And it gets even more complex if you count cards.
if ( num >= 17 )
hold
else
hit
if ( num > 21 )
bust
if ( num == 21 )
win
It's a bit more difficult than that! What about Aces that can be 1 or 11? Plus you don't just win if you get 21, you have a value that the dealer compares with each player and can lose, win, or push. You can also get a natural blackjack (A and 10 or face card) then the dealer wins except against players that also have a natural blackjack, then they push.
It's a bit more difficult than that! What about Aces that can be 1 or 11? Plus you don't just win if you get 21, you have a value that the dealer compares with each player and can lose, win, or push. You can also get a natural blackjack (A and 10 or face card) then the dealer wins except against players that also have a natural blackjack, then they push.
Oh there are public domain card images available.
well I am not going to do all of it .. lol -- that was just a taste of the logic minus the dealers hand comparison and everything else.
besides I got a figure mine out - you are already working on yours. lmao.
yeah and as far as the pictures of cards -- yeah what you said.
may be JUST maybe I'll switch and do 21 in Lazarus free pascal. I got a little more experience in that. and it is GUI then we can compare just cuz ..
oh and NO And it gets even more complex if you count cards.
that is like do not get caught in a casino doing that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.