between parentheses: funname ("string")
By reference. The name of the string is converted to a pointer (in C/C++) and given to the function as the address of the first element. (In Java, all objects are passed by reference, and there are no pointers.)
/* Write a function that will scan a character string passed as an argument & convert all lowercase characters into their uppercase characters*/ #include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> int str_upp(char c[]) { int i; char x; printf("\n \n"); for(i=0;i<strlen(c);i++) { x=toupper(c[i]); printf("%c",x); } return (0); } void main() { char c[10]; clrscr(); printf("Enter string : \n"); scanf("%s",c); str_upp(c) ; getch(); } /* Output: Enter string : Heloo HELOO */
in C: strstr, declared in string.h
You can use "string" class in C++ for string operations or you may use c style string functions as well. #include <string> String class in C++ provides all basic function to operate on strings. you may details descriptin at http://www.cplusplus.com/reference/string/string/
in C: atof, strtod, sscanf
In C programming, a string doesn't have a specific return type as it's essentially an array of characters. So, if a function is returning a string, it should be declared to return a pointer to a char (char*), since a string in C is represented as an array of characters terminated by a null character ('\0').
Use the atoi() or atol() function.
I guess you meant the following:'In C language, when you call a function,the parameters are passed by-value.'
The printf() function prints a formatted string.
A comma. For example, if your method name is Method1, and you wanted to pass String a, String b, and int c to it, you would do this: Method1(a, b, c);
Use the following function to count the number of digits in a string. size_t count_digits (const std::string& str) { size_t count = 0; for (std::string::const_iterator it=str.begin(); it!=str.end(); ++it) { const char& c = *it; if (c>='0' && c<='9'); ++count; } return count; }
GetA is a math function and not a string function.