Sie sind auf Seite 1von 5

REPORT

PROGRAMMING AND COMPUTER


APPLICATION PRACTICES

“STRING”

By:

Wildan Aghniya

17063048

ELECTRICAL ENGINERING EDUCATION

FACULTY OF ENGINEERING

PADANG STATE UNIVERSITY

2019
Purpose

1. Explaint about concept string.


2. Explaint operation I/O in string.
3. Explaint how to access element string.
4. Explaint various functions string.

Short Theory

Constanta and variable string

String is a form of data commonly used in programming languages for the purpose of
accommodating and manipulating text data, for example to store (save) a sentence. In C
language, strings are not a separate data type, but rather a collection of sequential character
values in the form of an array with one dimension.

Variable constanta. String Constants A string constant is written beginning and


ending with double quotes. String Variables. String variables are variables used to store string
values. Inisialisation string same laike array and the others, but in the end of the element must
have NULL.

Input and output data string


Input data string in variables can we do with the function gets() atau scanf().To
display the contents of a string variable, the function used is puts () or printf ().

Functions about string


Library functions for string operations, the prototypes are in the string.h title file.
Some of the library functions for string operations will be discussed below.

Function strcpy() to copy the value of string


This function is used to copy the original string to the destination string variable
including characters '\ 0'. The output of this function (return value) is the destination string.

Function strlen() to know the Value Length of the string


This function is used to get the number of characters in the string that becomes his
argument.

Function strcat() for mergestring value


Merging two string values can done with the strcat () library function by adding the
source string to the section end of the destination string. The output of this function is the
destination string.

Function strcmp() for combine two values string


Comparing two string values also cannot be used with the relationship operator,
because the operator is not for string operations. Comparing two string values can be done
with the strcmp () library function.
Work Steps

1. turn on the computer.


2. Select Start at the bottom left corner of the monitor.
3. Select program.
4. Select program dev c++.
5. If the dev c ++ screen is out, Select File.
6. Select new to open a new program, or open to fine the program you have been made
before.
7. Typing the program like what in the data od the program.
8. After typing is done, select file, save as, and give the name the program like what you
want in the practicum.
9. Compile and run the program to see the truth of the typing.
10. See the results monitored and recorded, then analyze the results of the experiment.
11. Do the prcticum for the next file program with the same way.

Result
1.

2.

3.
4.

5.

Analysis
The program above, using some function form C language.
 Input data string in variables can we do with the function gets() atau scanf().
 Function strcpy() to copy the value of string
 Function strlen() to know the Value Length of the string
 Function strcat() for mergestring value
 Function strcmp() for combine two values string
 Function strrchr() for stop and return the address of the last character found.

Conclusion
 Before you can work with strings, you need to declare them first. Since string is an
array of characters. You declare strings in a similar way like you do with arrays.
 You can use the scanf() function to read a string.
 You can use gets() function to read a line of string. And, you can use puts() to display the
string.
 Strings can be passed to a function in a similar way as arrays.
 To manipulated string, we can used function:
- strlen() - calculates length of a string
- strcpy() - copies a string to another
- strcmp() - compares two strings
- strcat() - concatenates two strings

references
 Jobsheet
 https://www.programiz.com/c-programming/c-string-examples

Das könnte Ihnen auch gefallen