P
pointer
I was wondering, is it better to start couple threads, or just put it
all in one. Well, i hope its ok this way...
First question is a function that puts integer n into a string s, using
the base n. The function is working correctly, but i was wondering is
there any better way of puting hex numbers in string?
sign * n%b+'7' I m using this line for storing letters for numbers
greater than 9. Isnt there a better way to put hex in there?
void itob(int n, char s[], int b)
{
int sign=1,i=0;
if (n < 0)
{
sign=-1;
}
do
{
if (n%b>9 || n%b<-9)
s[i++]= sign * n%b+'7';
else
s[i++]= sign * n%b+'0';
n /= b;
}
while(n!=0);
if (sign < 0)
{
s[i++] = '-';
}
s='\0';
reverse(s);
}
This case reports error duplicate cases. Why???
case 'a' || 'A':
case 'z' || 'Z':
this getchar is frustrating me...
while(getchar()!= EOF)
So if someone can explain this like im the third character in dumb and
dumber...
Let say im typing a line: and pressing ctr+z at the end of a line
This is a line^Z
after ctrl+z i press enter:
getchar(), is geting one character at a time and
eventually while looks like this
while (EOF != EOF)
why it doesnt exit while at that time???
What am i missing here??
all in one. Well, i hope its ok this way...
First question is a function that puts integer n into a string s, using
the base n. The function is working correctly, but i was wondering is
there any better way of puting hex numbers in string?
sign * n%b+'7' I m using this line for storing letters for numbers
greater than 9. Isnt there a better way to put hex in there?
void itob(int n, char s[], int b)
{
int sign=1,i=0;
if (n < 0)
{
sign=-1;
}
do
{
if (n%b>9 || n%b<-9)
s[i++]= sign * n%b+'7';
else
s[i++]= sign * n%b+'0';
n /= b;
}
while(n!=0);
if (sign < 0)
{
s[i++] = '-';
}
s='\0';
reverse(s);
}
This case reports error duplicate cases. Why???
case 'a' || 'A':
case 'z' || 'Z':
this getchar is frustrating me...
while(getchar()!= EOF)
So if someone can explain this like im the third character in dumb and
dumber...
Let say im typing a line: and pressing ctr+z at the end of a line
This is a line^Z
after ctrl+z i press enter:
getchar(), is geting one character at a time and
eventually while looks like this
while (EOF != EOF)
why it doesnt exit while at that time???
What am i missing here??