Beginning Programming with C For Dummies by Gookin Dan
Author:Gookin, Dan [Gookin, Dan]
Language: eng
Format: epub, mobi, pdf
Publisher: Wiley
Published: 2013-10-03T14:00:00+00:00
strlen()
Returns the length of a string, not counting the \0 or NULL character at the end of the string.
More string functions are available than are shown in Table 13-3. Many of them do specific things that require a deeper understanding of C. The ones shown in the table are the most common.
All the string functions in Table 13-3 require the string.h header file to be included with your source code:
#include <string.h>
On a Unix system, you can review all the string functions by typing the command man string in a terminal window.
Comparing text
Strings are compared by using the strcmp() function and all its cousins: strncmp(), strcasecmp(), and strncasecmp().
The string-comparison functions return an int value based on the result of the comparison: 0 for when the strings are equal, or a higher or lower int value based on whether the first string's value is greater than (higher in the alphabet) or less than (lower in the alphabet) the second string. Most of the time, you just check for 0.
Listing 13-3 uses the strcmp() function in Line 13 to compare the initialized string password with whatever text is read at Line 11, which is stored in the input array. The result of that operation is stored in the match variable, which is used in an if-else decision tree at Line 14 to display the results.
Listing 13-3: Let Me In
#include <stdio.h>
#include <string.h>
Download
Beginning Programming with C For Dummies by Gookin Dan.mobi
Beginning Programming with C For Dummies by Gookin Dan.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
C | C++ |
Tutorials | Visual C++ |
Hello! Python by Anthony Briggs(9911)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9794)
The Mikado Method by Ola Ellnestam Daniel Brolund(9775)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8293)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7775)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7758)
Grails in Action by Glen Smith Peter Ledbrook(7693)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Windows APT Warfare by Sheng-Hao Ma(6794)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6518)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6384)
Kotlin in Action by Dmitry Jemerov(5061)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4315)
Functional Programming in JavaScript by Mantyla Dan(4037)
Solidity Programming Essentials by Ritesh Modi(3977)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3766)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3710)
The Ultimate iOS Interview Playbook by Avi Tsadok(3685)
