hello i want to merge my GET and POST http request in one single program can any one help in doing this
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.
In the future please use [code][/code] tags to enclose your code, it separates it from you normal text and also retains the formatting of the code.
Also suggest you expand a bit more here on what you've tried. Members at LQ are volunteers and not paid support. Giving two clips of code, saying you wish to merge them, and not much more doesn't tell anyone what architecture you'd prefer the result to look like. Anyone can merge two functions with an if-else clause, however what do you wish it to do that will be additive beyond your simple question of combining? Did you wish to make a single function that does this using passing arguments to decide which actions to take?
Moving your question to the Programming forum for better exposure.
I want to call http request i.e., GET and POST request using C program which helps in getting the data from the server and the client can post the data into the server(using JSON data format). As you mentioned, here I want to make a single function that does this using passing arguments to decide which actions to take.
Yes I am not able to merge the code i.e., I am not able to write GET and POST methods in one single C Program. Can You please post for the same. It woould help me alot.
Yes I am not able to merge the code i.e., I am not able to write GET and POST methods in one single C Program. Can You please post for the same. It woould help me alot.
Thank You
No for a couple of reasons:
The members of LQ are volunteers and are not here to do your work for you
The intent of LQ is that you are trying to solve a problem and people here help you to solve that problem, yourself, and we'll advise about what to do
No one can write code where they do not know enough information about what you wish the higher level interface to this resultant function, so there is more information needed. However I get the impression that you are not able to provide any better description at this time.
If you were to receive code, what exactly could, or would you do with it? Since you are demonstrating the lack of capability to edit code, then one wonders whether or not you understand how to compile source into a usable result. Also, what if there are bugs? How will you deal with that?
This is the perfect opportunity for you to practice the essential life&job skill of: finding optimal web-search keywords!!!
I would start with: example c program http get post
Then add keywords to narrow it down. Use -word to eliminate things, e.g. -csharp
Try intitle:c Research: advanced google search operators
Life is 'no fun' if one asks others to "use the internet for me, so I don't have to learn to use the www"!!!
Enjoy and tell us what keywords you used in searching. Give us a copule links you found, with notes about what would be better for your desired goal. Then LQ people can guide & advise you, like the saying "teach a person to fish, and they will have food for life, but if you just give them a fish, they will eat for one day only".
rtmistler is a generous, caring, wise mentor, tho you might not realize that at first glance!!! Best wishes for success.
Edit addition: Here, it looks like they might be two different concepts. So maybe you could/would just append the two programs together, removing first return...} thru 2nd usage: ...}
IF I asked you: how do I combine these two commands into one, how would you answer?
Code:
ls .
df .
ls . ; df .
After you have made an attempt (tried something), come back for more help.
Tell us precisely what you tried, and clearly show how the results are not what you desire.
Please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls.
As rtmistler has already pointed out, it is not appropriate to ask others to write your code for you. Rather, you should try to work it out yourself and ask for help with specific problems when you cannot figure out how to do a particular thing.
In this case, if you already have working code for each use case and you wish to merge them into a single application which selects the intended use by command argument, you should be able to implement it almost as easily as you can write the description!
First, you need to detect the shell argument, argv, the user will pass to the application. A little research into those terms should show how that is commonly done. You might also want to look into getopt as a way to simplify argument handling.
Next, merge the code! As you already have working code for each case, that should be almost trivial!
If you get stuck somewhere along the way, reduce the problem to a simplest example which demonstrates the problem you are having and ask for help with that part of your code.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.