Thursday, 12 September 2013

Writing 2 strings on the same line in C

Writing 2 strings on the same line in C

So I want to make the hello.c program write both the first name and the
last name on one line so in this form but when I run my program in this
current form it gives me the error "expected â)â before string constant" I
think I have the rest of the code down because I have removed that line
and ran it and it works. So I just want to ask how to get 2 strings that I
have already pointed to to go on the same line.
This is my code
#include <stdio.h>
int main()
{
char firstname[20];
char lastname[20];
printf("What is your firstname?");
scanf("%s", firstname);
printf("What is your lastname?");
scanf("%s", lastname);
printf("Hello %s\n", firstname "%s", lastname);
printf("Welcome to CMPUT 201!");
}

No comments:

Post a Comment