free geoip

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
char s1[] = "example"; char s2[20] = "another example" would store the two strings as
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#1
char s1[] = "example"; char s2[20] = "another example" would store the two strings as follows: s1 |e|x|a|m|p|l|e|\0| s2 |a|n|o|t|h|e|r| |e|x|a|m|p|l|e|\0|?|?|?|?| sir this example is working. but i want to take name input from user including a space. in that case i am facing problem. i can read only first part of the name from array. for example if user enters TARIQ MEHMOOD. i can only read TARIQ. char name[20]; cout<<"please enter your complete name"'; cint>>name; cout<
Reply
#2
This is because you shouldn’t make use of the cin method of obtaining input from the user. The cin will stop when it sees a blank space.
If you want to use character array for complete name including blank space, you can use gets() function.
Try this code:

Code:
#include<iostream.h> main( ) { char name[20]; cout<<"Enter your full name"; gets(name); cout<<name; system("pause"); }
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why we write main rgc,char**argv in C++ 2012 Vuhelper 0 3,046 01-04-2012, 10:36 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,752 11-05-2011, 05:01 PM
Last Post: Vuhelper
  Memory pool & char array questions in C++ for 2011 Xpert 0 2,280 05-12-2011, 09:16 PM
Last Post: Xpert
  how we can store data into a file in C++ and java? Xpert 0 2,110 05-12-2011, 09:07 PM
Last Post: Xpert
  what will be the function of storeDetailOfData(). Is it store student/administrator/s saneha 1 2,203 05-02-2011, 05:53 PM
Last Post: Vuhelper
  what this function do ? void student ::setName (char *aName); saneha 1 2,151 05-02-2011, 06:35 AM
Last Post: Vuhelper
  const. pointer or pointer to const. char saneha 1 2,762 04-29-2011, 08:47 AM
Last Post: Vuhelper
  what is buffer ptr and char* in c ++ 2011 ? saneha 1 3,092 04-29-2011, 08:45 AM
Last Post: Vuhelper
  pasting my code down # include main () { char endp; char print; cout << "The print p sana.pari 1 1,943 04-24-2011, 06:02 PM
Last Post: Support
  i used Char data type to store a sentence but there is problem sana.pari 1 1,922 04-24-2011, 05:35 PM
Last Post: Support

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support