printf

Adding lots of values to a string Define the message Set the values within the message

Read More

Using char-Values

printf a value in a string Conversion Functions atoi – String To Int itoa – Int To String itoa is not part of ANSI C!  You can use this instead:

Read More

.Char based Strings General

Header Files #include <string.h> Creating Strings static const char *my_define = "/etc/sysconfig/network"; const char *mytext = "Hello World"; String Length int mytext_length = strlen(mytext); Does String Contain if (strncmp(*++argv, "O_RDONLY", 8) == 0) open_mode |= O_RDONLY; Copy String The preferred way strncpy (string_destination, string_source, max_length); //Note no null will be included if the string is […]

Read More

C++ Basic String Functions

  #include <string.h> strcpy – Copy string into string strcpy(s1, s2); Copies string s2 into string s1. strcat – Add string to end of string strcat(s1, s2); Concatenates string s2 onto the end of string s1. strlen – Get string length strlen(s1); Returns the length of string s1. strcmp – Compare strings strcmp(s1, s2); Returns 0 […]

Read More

CR and LF

UNIX only requries LF "\n" at the end of the line but will generally accept the windows CR+LF "\r\n" if present (apart from shell scripts)

Read More