![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2005
Posts: 19
Rep Power: 0
![]() |
Im very new to the whole C/C++ Things, but I am very good at Java so things arent that hard..
Um when I ask the user to put in their adress, and then I want it to print out the adress they entered it will only print everything they type in till a space.... char name[20], color[19], adress[20];
int x;
using namespace std;
int main(int argc, char *argv[])
{
int n[5];
int *prt;
prt = &n[0];
*prt = 3;
printf("What is your favorite number?");
scanf("%d", &x);
if(x>5)
{
printf("The number you chose is greater than 5!\n");
}
printf("\nWhat is your favorite color?");
scanf("%s", &color);
printf("\nWhats your Adress?");
scanf("%s", &adress);
printf("%s\n", adress);
printf("%d\n", *prt);
system("PAUSE");
return EXIT_SUCCESS;
} |
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
You could simply use the gets() method, instead of using scanf(). I never liked using scanf() for strings.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2005
Posts: 19
Rep Power: 0
![]() |
The gets() doesnt seem to work for me? It gives me an error on the stdio.h ? I am just replacing the scanf("%s", adress); to gets("%s", adress); Right?
Last edited by Havoc_101; Apr 10th, 2005 at 8:38 PM. |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
do you have the necessary header files in place?
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 | |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
Quote:
gets(adress);
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
|
#6 |
|
Newbie
Join Date: Apr 2005
Posts: 19
Rep Power: 0
![]() |
When i do it like that "gets(adress);" it just skips the question...
|
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|