answersLogoWhite

0


Best Answer

An array name is a pointer, so using arrays as pointers in function calls is implicit. An example is...

char a[] = "This is the source";

char b[sizeof(a)];

strcpy (b, a);

This is exactly the same1 as saying...

char a[] = "This is the source";

char b[sizeof(a)];

strcpy (&b[0], &a[0]);

... or ...

char* ap = "This is the source";

char* bp = malloc(strlen (ap)+1);

if (bp == NULL) { ... handle memory exception ... }

strcpy (bp, ap);

---------------------------------------------------------------------------------------------

1However, while a and ap have the same value in these examples, they are not really the same. You can assign a new value to ap, but not to a, because a is an r-value that is not allocated a place in memory, as opposed to ap, which is a l-value. To reinforce this, both *ap and a[0] are l-values, meaning the same thing, but not quite so for ap and a. Be careful - they both have the same value, but ap is an assignable l-value, while a is a un-assignable r-value.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you call string function using pointers in main program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


Write a Program to convert decimal number into hexadecimal no without using function and string?

This is not a question.


How to perform string operations like concatenation compare etc without using built in functions?

performing string operation using pointers


Piglatin string in c without using pointer?

Sure, you can write a function in C to convert a string to Pig Latin without using pointers by passing the string as a parameter and manipulating it directly within the function. You can split the string into words, check if a word starts with a vowel or consonant, and then apply the appropriate transformation following the rules of Pig Latin. Remember to allocate enough memory for the modified string to prevent buffer overflow.


How do you write a program using function that counts the number of vowels in a string in java language?

Use text-editor notepad++


Write a program to concate the string without using strconcat function?

If you don't need to preserve the first string you could just iterate over the second string and copy each character onto the end of the first string, then return that


Reverse of a string without using string handling function?

shashi


Write a c program to copy two strings using pointers?

nahi malum


What will be the program to arrange numbers stored in array in ascending order using pointers?

sorry


How do you reverse a string in PHP without using a function?

Without any function is impossible. So I'll assume you mean any coded function, in which case the predefined function below is your answer.$string = strrev($string);


How do you accept a string by using getch() function with an example?

explain about function call


Concat a string without using any inbuilt function in java?

Use "+". Example: String string = "does this answer " + "your question?";