G
gevadas
sample program
#include <iostream>
#include <vector>
using namespace std;
int find(char*& value,char** arr,int size)
{
for(int i = 0;i < size;i++)
{
if(strcmp(arr,value) == 0)
return i;
}
}
int main()
{
char* word = "two";
char* arr[4] = {"one","two","three","four"};
int res = find(word,arr,4);
cout << res;
}
the above program works fine even if the find was defined as follows
int find(char* value,char** arr,int size)
{
for(int i = 0;i < size;i++)
{
if(strcmp(arr,value) == 0)
return i;
}
}
It will be of great help if someone can tell me the difference b/w
char* and char&*
Thanks
Geaves
#include <iostream>
#include <vector>
using namespace std;
int find(char*& value,char** arr,int size)
{
for(int i = 0;i < size;i++)
{
if(strcmp(arr,value) == 0)
return i;
}
}
int main()
{
char* word = "two";
char* arr[4] = {"one","two","three","four"};
int res = find(word,arr,4);
cout << res;
}
the above program works fine even if the find was defined as follows
int find(char* value,char** arr,int size)
{
for(int i = 0;i < size;i++)
{
if(strcmp(arr,value) == 0)
return i;
}
}
It will be of great help if someone can tell me the difference b/w
char* and char&*
Thanks
Geaves