iam serching job somany comapnies asking this question but iam not getting lz reply anybody
Write a program in c for strcmp without using library function with pointers?
/*
* myStrCmp compares two strings s1 and s2 and returns an * integer value which would be 0 if the strings are equal or else the * difference of ascii of first letter.
*/
int myStrCmp(char *s1, char *s2)
{
int diff=0;
//check for invalid input or arguments.
if(s1==NULL || s2==NULL)
{
printf("Invalid input");
exit(1);
}
while(1)
{
// if either of string ends then break the loop.
if(*s1 =='\0' || *s2=='\0')
break;
//if the character is equal then increase the pointers and continue the loop.
if(*s1 ==*s2)
{
s1++;
s2++;
continue;
}
//if they are different then subtract and break the loop
if(*s1!=*s2)
{
diff=*s1-*s2;
break;
}
//end of infinie loop
}
return diff;
}
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;string.h%26gt;
main()
{
char a[30],b[30];
int n;
clrscr();
printf("enter string1 :\n");
gets(a);
printf("enter string2 :\n");
gets(b);
n=xstrcmp(a,b);
printf("the difference value=%d",n);
getch();
}
int xstrcmp(char *a,char *b)
{
while(*a==*b)
{
if(*a==NULL) //case when 2 strings
return(0); //entered are the same
a++;
b++;
}
return(*a-*b);
}
Friday, July 31, 2009
Write a program in c for strcmpi without using library function with pointers?
iam serching job somany comapnies asking this question but iam not getting lz reply anybody
Write a program in c for strcmpi without using library function with pointers?
int strcmpi(const char *s1, const char *s2)
{
for (;;){
if (*s1 != *s2) {
int c1 = toupper((unsigned char)*s1);
int c2 = toupper((unsigned char)*s2);
if (c2 != c1) {
return c2 %26gt; c1 ? -1 : 1;
}
} else {
if (*s1 == '\0') {
return 0;
}
}
++s1;
++s2;
}
}
Reply:is it c++ ?
Reply:You can't. You have to use libraries.
Write a program in c for strcmpi without using library function with pointers?
int strcmpi(const char *s1, const char *s2)
{
for (;;){
if (*s1 != *s2) {
int c1 = toupper((unsigned char)*s1);
int c2 = toupper((unsigned char)*s2);
if (c2 != c1) {
return c2 %26gt; c1 ? -1 : 1;
}
} else {
if (*s1 == '\0') {
return 0;
}
}
++s1;
++s2;
}
}
Reply:is it c++ ?
Reply:You can't. You have to use libraries.
Thursday, July 30, 2009
Need help understanding a simple C function?
Hi, I know java but am new to C. Although I do have the concept of what pointers are but I am not familiar with the syntax. Would somebody please explain the statements that involve the use of asterisks in the following function?
(Particularly the one that starts with a*)
void allocate_2d_array (int r, int c, double ***a)
{
double *storage;
int i;
storage = (double *) malloc (r * c * sizeof(double));
*a = (double **) malloc (r * sizeof(double *));
for (i = 0; i %26lt; r; i++)
(*a)[i] = %26amp;storage[i * c];
}
Thank you very much for your help.
Need help understanding a simple C function?
Okay, there are two symbols which are relevant in talking about pointers in C (as an aside, in C++ they are slightly extended so people can get confused. In particular %26amp; has one other meaning related to addresses). The two symbols are %26amp; which can be understood as "The Address of" and * which is "Pointer to".
Thus this function has 3 parameters coming in:
r: the number of elements in the array
c: the multiplier
and a pointer to a pointer to a pointer to a. Got that?
The first thing which is declared is a pointer to the array storage. Then we get the counter int, i, but we'll skip over that.
All storage is is an area of memory large enough to hold the address of a double (which is large enough to hold a pointer to an array of doubles, because arrays are usually passed as a pointer to the first element). That's why the storage= line is necessary. It sets aside a block of memory which is r*c*the size of a double bytes long. Since it uses malloc() which returns a void * it is necessary to cast the pointer as a double for it to be useable. That is what the (double *) does.
The next line I can parse better than I can understand. The an area of memory the size of a double * r is allocated, then cast as a pointer to a pointer, which is assigned to the address which is pointed to by a.
The line after that clarifies it a little, if you understand something called pointer decay. What this means is that since parameters are passed as values -- that is new variables are created in each function into which the values in the old variables are copied EXCEPT arrays which are passed as pointers to array[0] -- the address of the first element -- pointers to arrays and arrays can be treated exactly the same way. Each element in the array pointed to by a is assigned the address (the %26amp; operator) of the element in storage at i*c. Thus *a[0]==%26amp;storage[0], *a[1]==%26amp;storage[c], *a[2]==%26amp;storage[2c]... This is why this helps explain the above. It's an array of pointers to doubles.
The subject, as you can tell is very gnarly, and I'm pressed for time, I'm sorry to say. I'll leave you with a link in sources (which I did use) about pointer decay.
Reply:*a is a pointer variable. **a is a pointer to pointer. storage is apointer variable here.
and it has allocated memory dynamically using malloc.
Its syntax to allocate memory is (type of pointer variable)malloc(size).
(Particularly the one that starts with a*)
void allocate_2d_array (int r, int c, double ***a)
{
double *storage;
int i;
storage = (double *) malloc (r * c * sizeof(double));
*a = (double **) malloc (r * sizeof(double *));
for (i = 0; i %26lt; r; i++)
(*a)[i] = %26amp;storage[i * c];
}
Thank you very much for your help.
Need help understanding a simple C function?
Okay, there are two symbols which are relevant in talking about pointers in C (as an aside, in C++ they are slightly extended so people can get confused. In particular %26amp; has one other meaning related to addresses). The two symbols are %26amp; which can be understood as "The Address of" and * which is "Pointer to".
Thus this function has 3 parameters coming in:
r: the number of elements in the array
c: the multiplier
and a pointer to a pointer to a pointer to a. Got that?
The first thing which is declared is a pointer to the array storage. Then we get the counter int, i, but we'll skip over that.
All storage is is an area of memory large enough to hold the address of a double (which is large enough to hold a pointer to an array of doubles, because arrays are usually passed as a pointer to the first element). That's why the storage= line is necessary. It sets aside a block of memory which is r*c*the size of a double bytes long. Since it uses malloc() which returns a void * it is necessary to cast the pointer as a double for it to be useable. That is what the (double *) does.
The next line I can parse better than I can understand. The an area of memory the size of a double * r is allocated, then cast as a pointer to a pointer, which is assigned to the address which is pointed to by a.
The line after that clarifies it a little, if you understand something called pointer decay. What this means is that since parameters are passed as values -- that is new variables are created in each function into which the values in the old variables are copied EXCEPT arrays which are passed as pointers to array[0] -- the address of the first element -- pointers to arrays and arrays can be treated exactly the same way. Each element in the array pointed to by a is assigned the address (the %26amp; operator) of the element in storage at i*c. Thus *a[0]==%26amp;storage[0], *a[1]==%26amp;storage[c], *a[2]==%26amp;storage[2c]... This is why this helps explain the above. It's an array of pointers to doubles.
The subject, as you can tell is very gnarly, and I'm pressed for time, I'm sorry to say. I'll leave you with a link in sources (which I did use) about pointer decay.
Reply:*a is a pointer variable. **a is a pointer to pointer. storage is apointer variable here.
and it has allocated memory dynamically using malloc.
Its syntax to allocate memory is (type of pointer variable)malloc(size).
C++ programming help???
How do I make my version of C++ program for strcpy(char [] , char [] , int) without using pointers???
can someone help
C++ programming help???
That would involve creating a string class, which would include a member method, or operator that performs the assignment.
Reply:you can get help a programmer from
http://tutorialofc.blogspot.com/
i hope your problem slove here.
salary survey
can someone help
C++ programming help???
That would involve creating a string class, which would include a member method, or operator that performs the assignment.
Reply:you can get help a programmer from
http://tutorialofc.blogspot.com/
i hope your problem slove here.
salary survey
How do you write a GPA Calculator in C-Language?
Can anyone provide me with links to good C programming sites or perhaps give me some pointers on how to write one?
Thanks : - )
How do you write a GPA Calculator in C-Language?
The three URLs below are, in order, a great place to get a free compiler in any language and tutorials, a good programming forum for advice and a great little place to pick up example code. Use them if you'd like. Good luck!
Thanks : - )
How do you write a GPA Calculator in C-Language?
The three URLs below are, in order, a great place to get a free compiler in any language and tutorials, a good programming forum for advice and a great little place to pick up example code. Use them if you'd like. Good luck!
Pointers or advise on how to swallow his c*m when giving oral sex?
I have never let a guy "finish" in my mouth before when I give oral sex. It is something that I have made a personal commitment to myself that I would always save for my future husband so it would be special.
My fiancee is a wonderful man and I am looking forward to taking care of him like this... my question is, how on earth do I swallow this???
Although I am looking forward to doing this special thing (swallowing) for him when I give him oral sex once we are married--- it's just that I am kind of squeamish and nervous about how I'm going to "get it down" without gagging or throwing up, etc.
Do any of you ladies out there have any pointers on how to swallow when your man finishes in your mouth during oral sex?????
Pointers or advise on how to swallow his c*m when giving oral sex?
Here are a few things you might consider:
As a first step, try giving him oral sex using a flavored condom -- then you can get used to him climaxing without having to worry about swallowing.
Now, here's the big secret: if, as he c*ms, you swallow hard and fast, you'll hardly taste anything, and you won't be sitting with a mouthful trying to swallow. Try thinking of the load of c*m as your *reward* for the effort of giving him oral pleasure. Try to be eager to swallow -- then you'll just do it naturally. Swallowing quickly will also get rid of the taste quickly if you are worried about that.
C*m doesn't taste bad as such, but you'll need a bit of time to get used to it before you start to enjoy the taste. Trust me, though -- it's worth putting in the effort to get to like it :)
How deep can you go? If you can master deep-throating (where the tip reaches past the back of your throat), his c*m will shoot straight down into your stomach without you having to taste it. You can find tips on how to deep-throat all over the web.
Finally, you might try letting him c*m on your face or breasts. That might make you more comfortable with the idea of swallowing it.
Reply:My advice would be to start by letting him *** in your mouth, and be prepared to spit it out. If when the moment arrives you can swallow, that's fine, but don't give yourself an ultimatum about it. he will be delighted that you let him *** in your mouth, especially as you have reserved that treat for him and him alone.
The taste varies a lot depending on what he has eaten that day. Asparagus. for instance will give the semen a strong unpleasant taste.
All you can do is your best, and, if you can't manage it, it's not the end of the world.
Good luck.
Reply:I have worked out my boyfriend of 6 years tastes of warm goats cheese!!! My advice is to get really into it and just go for it! If like my boyfriend, he will be so happy to receive one I'm sure it won't make a difference!
Reply:here is a guys opinion.. if you dont like it.. you dont have to.. and if he didnt ask you to.. dont do it.. some men dont like it.. i like it before.. and had my ex's do it to me.. but.. after.. it feels different.. like i think less of them.. and im not a bad person.. and how hard is it to swallow? its not that bad.. all my ex tells me its sweet.. and its the food you eat that determines the taste..
Reply:yeah drink lots of water but dont do it if your not good with salty tastes
Reply:*sigh* I was never able to do that. And guess what? The bastard dumped me.
Anywayz some girls are just not able to do it. Trust me I'm one of them, and I tried many diff. ways. Just make him drink lots of water so it won't be as salty and then maybe you're gonna be able to....
Reply:Hey, it's your body. If you don't like it, you don't have to do it! No reason to get all sentimental about it......
That just doesn't make any sense to me. Why do you need to prove to yourself that you love him, by doing something that you find revolting?
There are much more pleasant ways of showing him that you love him unconditionally.....
My fiancee is a wonderful man and I am looking forward to taking care of him like this... my question is, how on earth do I swallow this???
Although I am looking forward to doing this special thing (swallowing) for him when I give him oral sex once we are married--- it's just that I am kind of squeamish and nervous about how I'm going to "get it down" without gagging or throwing up, etc.
Do any of you ladies out there have any pointers on how to swallow when your man finishes in your mouth during oral sex?????
Pointers or advise on how to swallow his c*m when giving oral sex?
Here are a few things you might consider:
As a first step, try giving him oral sex using a flavored condom -- then you can get used to him climaxing without having to worry about swallowing.
Now, here's the big secret: if, as he c*ms, you swallow hard and fast, you'll hardly taste anything, and you won't be sitting with a mouthful trying to swallow. Try thinking of the load of c*m as your *reward* for the effort of giving him oral pleasure. Try to be eager to swallow -- then you'll just do it naturally. Swallowing quickly will also get rid of the taste quickly if you are worried about that.
C*m doesn't taste bad as such, but you'll need a bit of time to get used to it before you start to enjoy the taste. Trust me, though -- it's worth putting in the effort to get to like it :)
How deep can you go? If you can master deep-throating (where the tip reaches past the back of your throat), his c*m will shoot straight down into your stomach without you having to taste it. You can find tips on how to deep-throat all over the web.
Finally, you might try letting him c*m on your face or breasts. That might make you more comfortable with the idea of swallowing it.
Reply:My advice would be to start by letting him *** in your mouth, and be prepared to spit it out. If when the moment arrives you can swallow, that's fine, but don't give yourself an ultimatum about it. he will be delighted that you let him *** in your mouth, especially as you have reserved that treat for him and him alone.
The taste varies a lot depending on what he has eaten that day. Asparagus. for instance will give the semen a strong unpleasant taste.
All you can do is your best, and, if you can't manage it, it's not the end of the world.
Good luck.
Reply:I have worked out my boyfriend of 6 years tastes of warm goats cheese!!! My advice is to get really into it and just go for it! If like my boyfriend, he will be so happy to receive one I'm sure it won't make a difference!
Reply:here is a guys opinion.. if you dont like it.. you dont have to.. and if he didnt ask you to.. dont do it.. some men dont like it.. i like it before.. and had my ex's do it to me.. but.. after.. it feels different.. like i think less of them.. and im not a bad person.. and how hard is it to swallow? its not that bad.. all my ex tells me its sweet.. and its the food you eat that determines the taste..
Reply:yeah drink lots of water but dont do it if your not good with salty tastes
Reply:*sigh* I was never able to do that. And guess what? The bastard dumped me.
Anywayz some girls are just not able to do it. Trust me I'm one of them, and I tried many diff. ways. Just make him drink lots of water so it won't be as salty and then maybe you're gonna be able to....
Reply:Hey, it's your body. If you don't like it, you don't have to do it! No reason to get all sentimental about it......
That just doesn't make any sense to me. Why do you need to prove to yourself that you love him, by doing something that you find revolting?
There are much more pleasant ways of showing him that you love him unconditionally.....
Plizzzzz help me write das program in C???
write a C program to reverse a character array using pointers????
Plizzzzz help me write das program in C???
/* Here's the entire code [including the main() function]. I have written a generic reverse function which can be used anywhere. */
#include %26lt;stdio.h%26gt;
void reverse ( char str[] )
{
char *ptr = str;
int arrLength = strlen( str );
int i;
char temp[arrLength];
for ( i = (arrLength-1); i %26gt;= 0; i-- )
{
temp[i] = *ptr++;
}
ptr = str;
for( i = 0; i %26lt; arrLength; i++ )
{
*ptr++ = temp[i];
}
}
int main()
{
char str[] = "This will be reversed";
reverse( str );
printf( "%s", str);
}
Reply:One problem - this won't actually compile.You can't use a variable value to declare an array on the stack. Report It
Reply:void reverseString( char array[] ) {
char *pHead = array;
char *pTail = pHead + strlen( array );
char temp;
while (pHead %26lt; --pTail) {
temp = *pHead;
*pHead++ = *pTail;
*pTail = temp;
}
} Report It
Reply:no
Reply://assume char[] array variable is array and is of length arrayLength;
int i;
char temp;
for(i=0; i%26lt;arrayLength/2; i++) {
temp = array[i];
array[i] = array[arrayLength-1-i];
array[arrayLength-1-i] = temp;
}
Reply:Hai here the program you asked
//Prog to rev array using pointers
#include%26lt;stdio.h%26gt;
main()
{
int a[10],*i,n,j=1;
printf("Enter the number of elements\n");
scanf("%d",%26amp;n);
printf("Enter the elements\n");
while(j%26lt;=n)
{
scanf("%d",%26amp;a[j]);
j++;
}
i=%26amp;a[n];
printf("The reversed array\n");
while(n!=0)
{
printf("%d\t",*i);
i--;
n--;
}
}
Reply:#include%26lt;string.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
char *s1,t;
int l;
s1=malloc(100);
scanf("%s",s1);
len=strlen(s1);
for(i=0 ;i%26lt;len;i++)
{
t=*(s+i);
*(s+i)=*(s+len-1);
*(s+len-1)=t;
}
getch();
}
Plizzzzz help me write das program in C???
/* Here's the entire code [including the main() function]. I have written a generic reverse function which can be used anywhere. */
#include %26lt;stdio.h%26gt;
void reverse ( char str[] )
{
char *ptr = str;
int arrLength = strlen( str );
int i;
char temp[arrLength];
for ( i = (arrLength-1); i %26gt;= 0; i-- )
{
temp[i] = *ptr++;
}
ptr = str;
for( i = 0; i %26lt; arrLength; i++ )
{
*ptr++ = temp[i];
}
}
int main()
{
char str[] = "This will be reversed";
reverse( str );
printf( "%s", str);
}
Reply:One problem - this won't actually compile.You can't use a variable value to declare an array on the stack. Report It
Reply:void reverseString( char array[] ) {
char *pHead = array;
char *pTail = pHead + strlen( array );
char temp;
while (pHead %26lt; --pTail) {
temp = *pHead;
*pHead++ = *pTail;
*pTail = temp;
}
} Report It
Reply:no
Reply://assume char[] array variable is array and is of length arrayLength;
int i;
char temp;
for(i=0; i%26lt;arrayLength/2; i++) {
temp = array[i];
array[i] = array[arrayLength-1-i];
array[arrayLength-1-i] = temp;
}
Reply:Hai here the program you asked
//Prog to rev array using pointers
#include%26lt;stdio.h%26gt;
main()
{
int a[10],*i,n,j=1;
printf("Enter the number of elements\n");
scanf("%d",%26amp;n);
printf("Enter the elements\n");
while(j%26lt;=n)
{
scanf("%d",%26amp;a[j]);
j++;
}
i=%26amp;a[n];
printf("The reversed array\n");
while(n!=0)
{
printf("%d\t",*i);
i--;
n--;
}
}
Reply:#include%26lt;string.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
char *s1,t;
int l;
s1=malloc(100);
scanf("%s",s1);
len=strlen(s1);
for(i=0 ;i%26lt;len;i++)
{
t=*(s+i);
*(s+i)=*(s+len-1);
*(s+len-1)=t;
}
getch();
}
Subscribe to:
Posts (Atom)