#include<iostream>
#include<string>
int main()
{
using std::string;
string a = "hand";
string b = "bag";
string c = a + b; // concatenation
}
Using Java:
class concat
{
public static void main(Strig Args[])
{
String str1 = "Wel";
String str2 = "Come";
String str3 = str1 + str2;
System.out.println("Concatenated:" + str3);
}
}
Using C:
#include <stdlib.h>
#include <stdio.h>
int main()
{
const char str1 [] = "Wel";
const char str2 [] = "Come";
char str3 [128], *p, *q;
q= str3;
for (p= str1; *p; ++p) *q++ = *p;
for (p= str2; *p; ++p) *q++ = *p;
*q= '\0';
printf("%s", str3);
return 0;
}
#include<iostream>
char* concat(char* str1, char* str2)
{
int len1 = strlen(str1);
int len2 = strlen(str2);
char * str = ( char* ) malloc( len1+ len2 + 1 );
char * ptr = str + len1;
memcpy( str, str1, len1 );
memcpy( ptr, str2, len2 + 1 );
ptr = NULL;
return( str );
}
int main()
{
char string1[] = "This is the first string";
char string2[] = " and this is the second string.";
char* string3 = concat( string1, string2 );
std::cout<<string3<<std::endl;
free( string3 );
return(0);
}
If you have let's say string1 = "blablabla1" and string2 = "blablabla2". To concatenate 2 strings you can use simbol +. So, string1 + string2 will be one string.
p1= from1;
p2= from2;
q= to;
while ((*q++= *p1++)!='\0');
--q;
while ((*q++= *p2++)!='\0');
Yes,we can compile our program without header file without any error,but we can not use any predefine functions like printf,scanf.
#include#include#includevoid main(){char str1[30],str2[30];int l1,l2,i;clrscr();gets(str1);gets(str2);l1=strlen(str1);l2=strlen(str2);for(i=0;i
Strings are a type of variable in computer programming. Simply put, they contain multiple characters which are "strung" together to make a piece of text. "Test", "House", and "Hello World!" are all excellent examples of what might be contained in a string. As a result, strings are used to store and convey any textual information.
yes we can run java program without using main. we can run program by declaring the variable static..
An interpreter reads program code (usually in source form, but sometimes in intermediate form) and directly executes it without conversion to the machine code of the computer it runs on.
Example1:sprintf (to, "%s%", from1, from2);Example2:size_t len1= strlen (from1);memcpy (to, from1, len1);strcpy (to+len1, from2);
C programs do not function without functions.
Functions are very important in C++, as you can't write the simplest program to print hello without using a function. Overall you can say that function are building blocks of a C++ program. Functions can also be defined by the programmer to reduce program size.
Yes,we can compile our program without header file without any error,but we can not use any predefine functions like printf,scanf.
you read the book how to solve by dromy.
It should work without any special action.
where can I get a business grant without government strings attached?
OS-dependent. For DOS use functions kbhit and getch from conio.h
It is not possible. In C, any program must have at least one function to be able to compile and execute properly: the function main()
One or more. (In other words: you cannot write a program without at least one function.)
Well I think the strings are as you cannot play the violin without the strings. from the belt man. Also the sound post in the violin is a major player in the sound making process
A broken violin.