Kamis, Mei 15, 2014

Define Value/Content of String Variable Mothode 2

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
  1. Open Dev C++ software
  2. File menu > New > Source File, then will be created a new worksheet titled Untitled1
  3. 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
  4. First, type minimal syntax required on C programming:

    main()
    {
    }


  5. Add getch() function in main() function to show program result while be Run:

    main()
    {
      getch();
    }


  6. 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();
    }


  7. 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();
    }


  8. 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();
    }


  9. 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();
    }


Hopefully useful, thank you... : )

0 komentar: