answersLogoWhite

0


Best Answer

#include,stdio.h>

main()

{

char string1[20],string2[20]

printf("enter the first string");

scanf("%s",string1);// reading the string1

printf("enter the second string");

scanf("%s", string2);// reading the the string2

printf( "the first string is %s",string1);// printing the string1

printf("the second string is %s",string2);// printing the string2

}

the problem of using scanf is that it does not take space. so we can use gets for it.

ie instead of scanf("%s",string1); we can use gets(string1); .

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can we read two strings using c program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a c program to copy two strings using pointers?

nahi malum


Write a program to compare two strings with out using strcmp function?

#include main() { //please read two strings int str1 and str2// while(str1[i]!='/0' &&str2[i]!='/0') if(str1[i]!=str2[i]) flag=1; if(flag==1) printf("equal"); } #include main() { //please read two strings int str1 and str2// while(str1[i]!='/0' &&str2[i]!='/0') if(str1[i]!=str2[i]) flag=1; if(flag==1) printf("equal"); }


Can you tell me a C program to find if the strings are equal using pointers?

It is called strcmp, part of the standard run-time library. Returns 0 if the two strings are equals, non-zero otherwise.


What is the Program for compare two strings using OR operator in java?

The String class includes two helpful methods: equals and compareTo.string1.equals(string2) will return true if the two strings contain the exact same charactersstring1.compareTo(string2) will return an int which describes the lexicographic relationship between the two strings. It will return a negative value if string1 is "less than" string2, a positive value if string1 is "greater than" string2, or zero if the two are equivalent strings.


C program to copy two strings in to a new string with out using stringcopy in borland c?

You can use so called concatenation of strings:{...string str1 = "something here";string str2 = " and something here";string newStr = str1 + str2;...}


'c' code to compare two strings using strcmp function?

char one [] = "A string" ;char two [] = "Different String" ;if (strcmp (one, two) == 0){puts ("The two strings are identical") ;}else{puts ("The two strings are different") ;}


How do you create program using characters strings in turbo c?

#include int main (int argc, char **argv){printf ("The name of this program is %s\n", argv[0]);return 0;}There's two character-string in this program, a literal and a variable. Go find them.


To copy two strings using strcpy?

Using strcpy and strcat. Or sprintf. Or strlen+memcpy. There are more than solutions.


Do you play two strings on a guitar at the same time?

Yes, when it is needed. YOu can use any combination of strings, so using all 6 at the same time is just as common as using one string.


How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


How to write a C program for concatenation of two strings using stack?

#include #include using std::cin;using std::cout;using std::endl;using std::string;int main(void){string str1 = "nothing here";cout str1;string str2 = "neither here";cout str2;string srt = "result here";cout


What did David's slingshot look like?

It was a pouch with two strings attached to it.