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.
IN C what will be the actual execution when the for loop syntax is for (initializer;incrementation;condition)
eg:
for(i=1;i<100;i++)
{
printf("%d",i);
}
It will be
123456789...99
Unless your libc doesn't flush stdout on close. Or are you asking how it works, in which, case, It's equavalent to:
initializer;
while(condition){
...
incrementation
}
or
i=1;
while(i<100){
printf("%d", i);
i++;
}
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 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 10 years ago.
int a = 8;
if (a==8)
printf("x");
else
printf("y");
Though a is equal to 8, it outputs y.
The code above always prints x. If your code prints something else, then you omitted vital information in your question.
To find out what that might be, try this:
Insert #undef a before the int a = 8; to make sure there isn't a C preprocessor macro that messes with the code.
Swap the condition to see if a is really what you expect:
if( 8 == a )
This little trick also prevents you from the accidental assignment bug (if( a = 8 ))
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]));
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.
How to Optimize this piece of C code...??
int c = no, diff = u - d;
while (no--)
for (d = u; d < p[no]; d += diff)
c++;
The best optimization, for size, speed, cleverness, clarity, and anything else you may think of, is to have no code.
So, just remove those 4 lines from your source(s) and you've optimized your code.
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.
please tell me about #define
i want to execute c program when i wrote p in the place of printf
using #define but how please tell me...
#define p printf
int main() {
p("hello world");
return 0;
}
#define P(X) printf("%d\n",X)
This only works for int tho. careful.