2 String
2 String
2 String
h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define N 5
#define MAX_LEN 15
int main()
{
//-----------demo1----------//
//without size
// char date1[] = "June 14";
// char date2[] = {'M','a','y',' ','1','4','\0'};
////with size
// char date1[MAX_LEN+1] = "June 14"; // +1 for '\0'
// char date2[MAX_LEN+1] = "May 14";
// //printing string by printf, puts
// printf("%s\n", date1);
// printf("%s\n", date2);
// puts(date2);
//-----------demo2----------//
// printf("%s\n", date1);
// printf("%s\n", date2);
//-----------demo3----------//
//------scanf(), fgets() and getchar() to read string------
//-------1. read word vs. many words
//-------2. If inputs more than max_size -> scanf will prompt error but
//fgets will auto keep the value + \0
//Welcome to ICT, Hello World!, Fundamental of programming, MUICT,
a_very_long_sentence
//it can be space, enter, tab it will stop reading and the null char (\0) will
be added automatically
// printf("\n");
//-----------demo4----------//
//15
/*
char str1[MAX_LEN] = "Google"; // if no MAX_LEN, we cannot store a longer
string.
char str2[MAX_LEN] = "Microsoft";
//str2 = str1; //Error !! --> Cannot assign the value with ‘=’
//strcpy(str2, str1); // strcpy() is typically used to assign string value
strcpy(str1, str2);
printf("%s %s\n", str1, str2);
*/
//
//-----------demo5----------//
//strcpy(str3, str1); // Error !! --> the size of str3 is smaller than str1
//printf("%s %s\n", str1, str3);
//-----------demo6----------//
// strcpy(fullname, fname);
// strcat(fullname, " ");
// strcat(fullname, lname);
//for loop
/*
char str[] = "This is an Alphabet.";
int num_a = 0;
for(int i = 0; i<strlen(str); i++){
if (str[i] != '\0') { // Check for end-of-string
if (str[i] == 'A' || str[i] == 'a') {
num_a++;
}
}else{
break;
}
}
printf("%d\n", num_a);
*/
//strcpy(str2, str1);
printf("%s\n", str2);
*/
return 0;
}