I'm not sure if I'm doing this part correctly, the part where I have to make it all lower case then to all upper case, then just first name. #include <iostream> #include <cstring> #include <stdio.h> using namespace std; int main() { char a[3][14] = { "Barack ", "H", " Obama" }; cout << "Enter your full name: "; cout << a[0] << a[1] << a[2] << endl; //Find length of name int i = strlen(a[0]); int j = strlen(a[1]); int k = strlen(a[2]); cout << "\tYou name's length is " << (i+j+k) << endl; tolower (a[0][0]); tolower (a[0][1]); tolower (a[0][2]); …

Member Avatar
Member Avatar
+0 forum 3

Hello, I was recently looking through some of my code and found what I believe to be a memory leak. It is in a function that appends two strings and I am not sure how to resolve it. Here is the function: const char *strapp(const char *str,const char *s) { int size,strSize,sSize; for (strSize=0;str[strSize];++strSize); for (sSize=0;s[sSize];++sSize); size=strSize+sSize; char *ret=new char[size+1]; for (size_t i=0; i<strSize; ++i) ret[i]=str[i]; for (size_t i=0; i<sSize; ++i) ret[strSize+i]=s[i]; ret[size]=0; return ret; } Note that this includes a `new` operator but would leave it up to the untrustworthy user of the function to `delete` the resulting pointer …

Member Avatar
Member Avatar
+0 forum 7

I'm trying to extract the value of the coeffecients and the exponent from a polynomial. I have already succeeded in extracting the coeffients using strtok. I applied the same concept to find the exponent, but I don't know how to use strtok to extract the string AFTER the delimiters or skip the first character, and strtok is the only extracting tool I know. The program is developed in C++ but strtok uses c codes so I just post it here This is main() #include <iostream> #include <cctype> #include <cstring> #include <cstdlib> #include <string> using namespace std; void extractCoeff (char *str, …

Member Avatar
Member Avatar
+0 forum 1

I know that this [ICODE]#define QUOTE(X) #X[/ICODE] turns X into a c-string version of whatever is passed to it. my question is if there is a way to do this in reverse ie: [ICODE]#define DEQUOTEANDCALLFUNCTIONORCLASSWITHGIVENNAME(X) (X#)()[/ICODE] is this possible?

Member Avatar
Member Avatar
+1 forum 3

I've been coding in c++ for a while now, and I use string variables quite a lot. One day, I stumbled upon a char* which can also be used to "store" a string of characters, and it's been bothering me ever since that I don't really know what a string is (and by "string", I don't mean a line of characters, I mean the <cstring> string). Is it a class? A struct? A typedef? I would really like someone to give me an intermediate explanation of the inner workings of string variables. Thanks a lot

Member Avatar
Member Avatar
+0 forum 2

I would like to convert a C++ string that the user inputs to a c string. The problem is I have no idea how long the c++ string will be and i know the c string has to have one extra space for \n. Is there a way to apply the lenght of the inputed string into the cstring? egg string userInput; char userInputC[?????];

Member Avatar
Member Avatar
+0 forum 1

The End.