It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
map[0][4]='\0';
city1[0][4]='\0';
strcpy(map[0],city1[0]);
map[0][0]='z';
printf("%s",map[0]);
printf("%s",city1[0]);
printf("%d \n",strcmp(map[0],city1[0]));
The output of this function is zail
nail
12
Why it is so? What I did not understand about strcmp? Why 12 and not any other number?
To answer your question,
strcmp("zail", "nail")
is evaluating to 12 because it's subtracting the 'n' in "nail" from the 'z' in "zail", and 'z' - 'n' = 12.
You're getting random junk because you're not initializing your arrays properly.
Instead of
map[0][4]='\0';
city1[0][4]='\0';
Try
memset(map[0], '\0', sizeof(map[0]));
memset(city1[0], '\0', sizeof(city1[0]));
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a 4 digit decimal number say 1234. I want to split this number into 4 separate ASCII values like '1','2','3','4'.
The process should not include division operation or integer to string conversion etc.
You want to extract each digit of the number and add '0'. If this is against your requirements, feel free to ignore.
you can anytime change division operator subtraction anytime.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have simple question.. when I used read method in pipes, what argument return? Example:
temp = read(fb[0],readbuffer,sizeof(readbuffer));
what will return to temp?
The number of bytes read from the pipe
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Just the question! Why can it not sort more than 254859 elements?
It can, but:
It takes forever
You need to use data types that can hold enough elements.
Other than that, there is absolutely no reason why the algorithm itself would be limited to any particular input size.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Which is executes faster?
1:
n = n << 1;
2:
n = n + n;
Any good compiler will end up making them both the same, so I can't imagine it matters.
In principle, << can be faster for signed types because it's less-strictly defined. n+n is defined whenever it doesn't overflow, but n<<1 is defined only when n is non-negative and the result does not overflow.
In reality, the compiler will generate the exact same machine code for both.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I want to use abc1 ,abc2, abc3,abc4,..abc100,as struct variable name. But I don't know how to set this? have no idea.
Can anybody help me out?
Thanks indeed.
It sounds like you're looking for an array.
typedef struct {
/* ... */
} whatever;
whatever abc[100];
abc[0] = xxx;
abc[3] = yyy;