Category Archives: C library function

How to count numbers from string ?

code:

 

Some string functions

puts()

in c i will implement.
Main job of this function is to print a new line autoamtically where printf() does not give this.

example:

putchar()

The actual work of putchar is it display string as character by character putchar is a macro that outputs character on stdout.

and the basic is : putchar(‘a’)    // it will print a
and putchar(a);     //it will print the value in stored in a
And the basic parameters of this is:
int putchar(int c);

Take input in string:

In string we don’t mention ampersand & sign as string automatically take it as address.

catcpy.c

String equality:

String Lower:

String Upper:

strdup.c

strstr.c

 

 

Reference for some examples:
http://fresh2refresh.com/c-programming/c-strings/

http://www.apiexamples.com/c/string/strstr.html

c library function strcmp()

http://www.cplusplus.com/reference/cstring/strcmp/

http://www.tutorialspoint.com/c_standard_library/c_function_strcmp.htm

for the pseudocode: http://stackoverflow.com/questions/12136329/how-does-strcmp-work

http://en.cppreference.com/w/c/string/byte/strncmp

example:

here we are actually comparing the contents of lhs and contents of rhs that is passing from the main function.

declaration can be done by this in nay function

int strcmp(const char* str1,const char* str2)

algorithm should be like this:

Two things to remember we are defining here the address value not the length of the string and so it is the comparison between contents of the strings not the length . 🙂