This document discusses strings in C programming. It defines strings as arrays of characters ending with a null character. It covers declaring and initializing strings, the difference between character and integer values, string input/output functions like scanf and printf, and character handling library functions. It also provides examples of using strings, checking string length and converting strings to integers.
At the end of this lecture students should be able to;
Define the declaration C strings.
Compare fixed length and variable length string.
Apply strings for functions.
Define string handling functions.
Apply taught concepts for writing programs.
At the end of this lecture students should be able to;
Define the declaration C strings.
Compare fixed length and variable length string.
Apply strings for functions.
Define string handling functions.
Apply taught concepts for writing programs.
Introduction to strings in C language
Declarations/initialization of character array and
String Library function like gets();strlen(),strcat(), strncat(),strcmp(),strncmp(),strrev(), strstr(), strnstr(), strcpy(),strncpy();
A string is a data type used in programming, such as an integer and floating point unit, but is used to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers. For example, the word "hamburger" and the phrase "I ate 3 hamburgers" are both strings.
C Programming/Strings. A string in C is merely an array of characters. The length of a string is determined by a terminating null character: '-' . So, a string with the contents, say, "abc" has four characters: 'a' , 'b' , 'c' , and the terminating null character.
Introduction to strings in C language
Declarations/initialization of character array and
String Library function like gets();strlen(),strcat(), strncat(),strcmp(),strncmp(),strrev(), strstr(), strnstr(), strcpy(),strncpy();
A string is a data type used in programming, such as an integer and floating point unit, but is used to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers. For example, the word "hamburger" and the phrase "I ate 3 hamburgers" are both strings.
C Programming/Strings. A string in C is merely an array of characters. The length of a string is determined by a terminating null character: '-' . So, a string with the contents, say, "abc" has four characters: 'a' , 'b' , 'c' , and the terminating null character.
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptxAbhimanyuChaure
This is an presentation of c programming language which is taught at indian institute of technology kanpur in first year first semester under bachelor of technology or bachelor of science.
Asit Bangalore is providing best Programming course "C LANGUAGE" and helped them to take internship program which is helped to get real time exposure and placements in global world. For more details Please visit our website.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
Automobile Management System Project Report.pdfKamal Acharya
The proposed project is developed to manage the automobile in the automobile dealer company. The main module in this project is login, automobile management, customer management, sales, complaints and reports. The first module is the login. The automobile showroom owner should login to the project for usage. The username and password are verified and if it is correct, next form opens. If the username and password are not correct, it shows the error message.
When a customer search for a automobile, if the automobile is available, they will be taken to a page that shows the details of the automobile including automobile name, automobile ID, quantity, price etc. “Automobile Management System” is useful for maintaining automobiles, customers effectively and hence helps for establishing good relation between customer and automobile organization. It contains various customized modules for effectively maintaining automobiles and stock information accurately and safely.
When the automobile is sold to the customer, stock will be reduced automatically. When a new purchase is made, stock will be increased automatically. While selecting automobiles for sale, the proposed software will automatically check for total number of available stock of that particular item, if the total stock of that particular item is less than 5, software will notify the user to purchase the particular item.
Also when the user tries to sale items which are not in stock, the system will prompt the user that the stock is not enough. Customers of this system can search for a automobile; can purchase a automobile easily by selecting fast. On the other hand the stock of automobiles can be maintained perfectly by the automobile shop manager overcoming the drawbacks of existing system.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
Democratizing Fuzzing at Scale by Abhishek Aryaabh.arya
Presented at NUS: Fuzzing and Software Security Summer School 2024
This keynote talks about the democratization of fuzzing at scale, highlighting the collaboration between open source communities, academia, and industry to advance the field of fuzzing. It delves into the history of fuzzing, the development of scalable fuzzing platforms, and the empowerment of community-driven research. The talk will further discuss recent advancements leveraging AI/ML and offer insights into the future evolution of the fuzzing landscape.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Quality defects in TMT Bars, Possible causes and Potential Solutions.PrashantGoswami42
Maintaining high-quality standards in the production of TMT bars is crucial for ensuring structural integrity in construction. Addressing common defects through careful monitoring, standardized processes, and advanced technology can significantly improve the quality of TMT bars. Continuous training and adherence to quality control measures will also play a pivotal role in minimizing these defects.
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSEDuvanRamosGarzon1
AIRCRAFT GENERAL
The Single Aisle is the most advanced family aircraft in service today, with fly-by-wire flight controls.
The A318, A319, A320 and A321 are twin-engine subsonic medium range aircraft.
The family offers a choice of engines
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
2. Fundamentals of Characters and Strings
• Characters in C consist of any printable or nonprintable character in
the computer’s character set including lowercase letters, uppercase
letters, decimal digits, special characters and escape sequences.
• A character is usually stored in the computer as an 8-bits (1 byte)
integer.
• The integer value stored for a character depends on the character
set used by the computer on which the program is running.
• There are two commonly used character sets:
• ASCII (American Standard Code for Information Interchange)
• EBCDIC (Extended Binary Coded Decimal Interchange Code)
3. Difference Between an Integer Digit and a
Character Digit
• char num = 1 and char num = ‘1’ are not the same.
• char num = 1 is represented in the computer as
00000001.
• char num = ‘1’ on the other hand is number 49 according
to the ASCII character set. Therefore, it is represented in
the computer as 00110001.
4. Example: ASCII Character
#include <stdio.h>
void main(void)
{
char my_A = 'A';
char my_Z = 'Z';
char my_a = 'a';
char my_z = 'z';
printf("nASCII value for A is %d", my_A);
printf("nASCII value for Z is %d",my_Z);
printf("nASCII value for a is %d", my_a);
printf("nASCII value for z is %d",my_z);
printf("n");
printf("n65 in ASCII represents %c",65);
printf("n90 in ASCII represents %c",90);
printf("n97 in ASCII represents %c",97);
printf("n122 in ASCII represents %c",122);
}
5. Sample Output
ASCII value for A is 65
ASCII value for Z is 90
ASCII value for a is 97
ASCII value for z is 122
65 in ASCII represents A
90 in ASCII represents Z
97 in ASCII represents a
122 in ASCII represents z
6. Example
#include <stdio.h>
int main()
{
char ch;
printf("enter a character: ");
scanf("%c", &ch);
if (ch >= ‘A’ && ch <= ‘Z’)
printf("ncapital lettern");
return 0;
}
equivalent to
#include <stdio.h>
int main()
{
char ch;
printf("enter a character: ");
scanf("%c", &ch);
if (ch >= 65 && ch <= 90)
printf("ncapital lettern");
return 0;
}
7. String Declaration and Initialization
• A string in C is an array of characters ending with the null character
(‘0’). It is written inside a double quotation mark (“ ”)
• A string can be assigned (in a declaration) to a char array:
• char color[6] = “green”;
color
0 1 2 3 4 5
‘g’ ‘r’ ‘e’ ‘e’ ‘n’ ‘0’
8. String Declaration and Initialization
• A string can also be defined by specifying the individual characters:
• char color[ ] = {‘g’, ‘r’, ‘e’, ‘e’, ‘n’, ‘0’};
color
0 1 2 3 4 5
‘g’ ‘r’ ‘e’ ‘e’ ‘n’ ‘0’
9. String Declaration and Initialization
• Notice that even though there are only five characters in the
word ‘green’, six characters are stored in the computer. The
last character, the character ‘0’, is the NULL character which
indicates the end of the string.
• Therefore, if an array of characters is to be used to store a
string, the array must be large enough to store the string and
its terminating NULL character.
10. String Declaration and Initialization
• If we happen to declare a string like this:
char my_drink[3] = “tea”;
• We will get the following syntax error:
error C2117: 'tea' : array bounds overflow
• Instead, we need to at least declare the array with (the size of
the string + 1) to accommodate the null terminating character
‘0’.
char my_drink[4] = “tea”;
11. String Declaration and Initialization
• We can initialize string variables at compile time such as;
• char name[10] = “Arris”;
• This initialization creates the following spaces in storage :
0 1 2 3 4 5 6 7 8 9
‘A’ ‘r’ ‘r’ ‘i’ ‘s’ ‘0’ ‘0’ ‘0’ ‘0’ ‘0’
name
12. Example: String and ‘0’
#include <stdio.h>
void main()
{
char sentence[] = "I love Bangladesh";
int i, count = 0;
for (i = 0; sentence[i] != '0'; i++)
count++;
printf(“%s has %d characters including the whitespace",
sentence, count);
}
13. Example: String and ‘0’
#include <stdio.h>
void main()
{
char sentence[] = "I love Bangladesh";
int i, count = 0;
for (i = 0; sentence[i] != '0'; i++)
count++;
printf(“%s has %d characters including the whitespace",
sentence, count);
}
Sample output:
I love Bangladesh has 15 characters including the whitespace
14. String Input/Output Functions
• Standard Functions Input
• scanf( )
• gets( )
• Standard Functions Output
• printf( )
• puts( )
• Use scanf function together with the format specifier %s for
interactive input string. (no whitespace character)
• If the string to be read as an input has embedded whitespace
characters, use standard gets function.
15. Example: gets, puts, scanf and
printf
#include <stdio.h>
int main()
{
char string1[50];
char string2[50];
printf("Enter a string less than 50 characters with
spaces: n");
gets(string1);
printf("nYou have entered: ");
puts(string1);
printf("nTry entering a string less than 50
characters, with spaces: n");
scanf("%s", string2);
printf("nYou have entered: %sn", string2);
return 0;
}
16. Example: gets, puts, scanf and
printf
Sample output
Enter a string less than 50 characters with spaces:
hello world
You have entered: hello world
Try entering a string less than 50 characters, with spaces:
hello world
You have entered: hello
17. Character Handling Library
• Character handling library includes several function that perform
useful tests and manipulation of character data.
• Each function receives a character, represented as an int or EOF, as
an argument.
• When using functions from the character handling library, the
header file <ctype.h> needs to be included.
• Characters in these functions are manipulated as integers (since a
character is basically a 1 byte integer).
18. Functions in <ctype.h>
Prototype Function Descriptions
int isdigit(int c) Returns a true if value c is a digit, and 0 (false) otherwise.
int isalpha(int c) Returns a true if value c is a letter, and 0 otherwise.
int isalnum(int c) Returns a true if value c is a digit or a letter, and 0 otherwise.
int isxdigit(int c) Returns a true value if c is a hexadecimal digit character, and 0 otherwise.
int islower(int c) Returns a true value if c is a lowercase letter, and 0 otherwise.
int isupper(int c) Returns a true value if c is an uppercase letter, and 0 otherwise.
int tolower(int c) If c is an uppercase letter, tolower returns c as a lowercase letter. Otherwise, tolower returns the
argument unchanged.
int toupper(int c) If c is a lowercase letter, toupper returns c as an uppercase letter. Otherwise toupper returns the
argument unchanged.
int isspace(int c) Returns true if c is a white space character – newline (‘n’), space (‘ ’), form feed (‘f’), carriage
return (‘r’), horizontal tab (‘t’) or vertical tab (‘v’) – and 0 otherwise.
int iscntrl(int c) Returns a true if c is a control character, and 0 otherwise.
int ispunct(int c) Returns a true if c is a printing character other than a space, a digit or a letter, and 0 otherwise.
int isprint(int c) Returns a true value if c is a printing character including space (‘ ’), and 0 otherwise.
int isgraph(int c) Returns a true value if c is a printing character other than space (‘ ’), and 0 otherwise.
19. String Conversion Functions
• These functions convert strings of digits to integer and floating-
point values.
• To use these functions, the general utilities library <stdlib.h>,
needs to be included.
• Example:
• atoi: string to int
• atof: string to double
20. Example
/*1. Converting a String Into an int Using
atoi. */
#include <stdio.h>
#include <stdlib.h>
int main()
{
char str1[ ] = "124z3yu87";
char str2[ ] = "-3.4";
char str3[ ] = "e24";
int i1 = atoi(str1), i2 = atoi(str2),
i3 = atoi(str3);
printf("i1: %dn", i1);
printf("i2: %dn", i2);
printf("i3: %dn", i3);
return 0;
}
21. Example
/*1. Converting a String Into an int Using
atoi. */
#include <stdio.h>
#include <stdlib.h>
int main()
{
char str1[ ] = "124z3yu87";
char str2[ ] = "-3.4";
char str3[ ] = "e24";
int i1 = atoi(str1), i2 = atoi(str2),
i3 = atoi(str3);
printf("i1: %dn", i1);
printf("i2: %dn", i2);
printf("i3: %dn", i3);
return 0;
}
Output:
i1: 124
i2: -3
i3: 0