On this section will be explained how to define string variable value/string variable content by using methode 2 on C programming, please check it out!
Example of defining of string variable value/string variable contenr on C programming language syntax
Example of defining of string variable value/string variable contenr on C programming language syntax
- Open Dev C++ software
- File menu > New > Source File, then will be created a new worksheet titled Untitled1
- File menu > Save As. On Save as type: choose C source files (*.c) and on File name, example we give name define string methode 2.c
- First, type minimal syntax required on C programming:
main()
{
} - Add getch() function in main() function to show program result while be Run:
main()
{
getch();
} - Define name a string variable in which after name of the string variable given mark [ ] and directly defined its string value using equals mark (=) and double quotes mark (" ")
main()
{
char name_of_string [] = "Thariq bin Ziyad";
getch();
} - To show string value has been defined on program syntax, use printf() function without using code %s
main()
{
char name_of_string [] = "Thariq bin Ziyad";
printf(name_of_string);
getch();
} - Can be added sentence, and to show its string value use code %s
main()
{
char name_of_string [] = "Thariq bin Ziyad";
printf("String content is defined on program syntax is: %s", name_of_string);
getch();
} - Can be also added other string variable in which their value is also defined on program syntax:
main()
{
char name_of_string1 [] = "Thariq bin Ziyad";
char name_of_string2 [] = "Learning C programming laguange";
printf("First string content is defined is: %s", name_of_string1);
printf("\n\nSecond string content is defined is: %s", name_of_string2);
getch();
}
0 komentar:
Posting Komentar