Using Pointers With Strings
Right, I am getting into a little bit of trouble here!!! ...I know about pointers and how they work, and have used many in the past for different applications etc.
Basically, I am trying to find a way to save users input through different menus so I can create a request that gets sent to the server which reads the request and responds!
I dont want an answer, I really would like an example, I have looked everywhere; but am going nowhere!!!!
So, for example, if i am selling a car to the user, I want to gather information about what they want; color engine size etc....
Please enter the color you want
Please choose an engine size
Please choose style of car
OK, so the user goes through the menu choosing options, but what i want to have is a pointer to a string (or memory containing chars) that represents a request such as:
(using the car protocol that i just made up off the top of my head!)
"POST MYCAR CP/1.0\r\nCar-Options:#color;red#engine;1.0#style;sports\r\n\r\n "
I really would like to know how to save user input into memory or a string buffer so it creates the message as it goes through the different stages!
I started off with scanf("%s", buffer) and had a different char array for each one, but it was set to 256 chars long, so there was a lot of rubbish data inbetween each of the elements in the request!!!! ...If anyone understands what I am trying to get at, please please, your help is much appriciated!!!!!
THANKS TO EVERYONE WHO READS THIS!!!!!!!!!!!