473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

need to convert a char to an hexadecmial value

Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

whats the logic of conversion...

Mar 27 '06 #1
27 1927

sa*****@yahoo.co.in wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values


Use the following as an example.

Regards,
Ralph

#include <stdio.h>

int main(void)
{
char c = ' ';
char hex[4];
char *hp = &hex[1];
hex[0] = '%';
hex[3] = '\0';

snprintf(hp, 3, "%x", c);
printf("%s\n", hex);
return 0;
}

--
Ralph Moritz

Laugh at your problems; everybody else does.

Mar 27 '06 #2
sa*****@yahoo.co.in wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

whats the logic of conversion...


#include <stdio.h>
#include <stdlib.h>

int main(void) {
char arr[3] = { 'A', 'B', 'C' };
short cnt;

for(cnt = 0; cnt < 3; cnt++)
printf("%%%x ", arr[cnt]);

fflush(stdout);
return 0;
}

Mar 27 '06 #3
On 2006-03-27, sa*****@yahoo.co.in <sa*****@yahoo.co.in> wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

whats the logic of conversion...


1) learn how to step along a string e.g

for(int i=0;i<strlen(s);i++)
char myChar = s[i];

2) look up in the c reference how to convert values using programs
like printf and sprintf.

3) look up the "%.1s" type format specifier for printf/sprintf

good luck!
Mar 27 '06 #4
Ralph A. Moritz wrote:
sa*****@yahoo.co.in wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values


Use the following as an example.

Regards,
Ralph

#include <stdio.h>

int main(void)
{
char c = ' ';
char hex[4];
char *hp = &hex[1];
hex[0] = '%';
hex[3] = '\0';

snprintf(hp, 3, "%x", c);
printf("%s\n", hex);
return 0;
}


Why so much complication for such a simple task? Besides it doesn't
quite do what the OP wants.

Mar 27 '06 #5
santosh wrote:
Why so much complication for such a simple task?


You're right.; my code is not optimal. Your example is much better :-)

Mar 27 '06 #6
<sa*****@yahoo.co.in> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

whats the logic of conversion...


There is actually no conversion performed. You may choose to view the value
stored in: char a = 'A'; as a hexadecimal number. You can also print the
corresponding character to this value in your character set, which you told
us is ASCII. The thing is the value resides there, it is a matter of how you
choose to interpret it.
Mar 27 '06 #7
sa*****@yahoo.co.in wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

#include <stdio.h>
int main(void)
{
unsigned char src[] = "ABC", *t;
printf("For this implementation, the string \"%s\"\n"
"has the encoding: \n", src);
for (t = src; *t; t++)
printf("%%%x", *t);
putchar('\n');
return 0;
}

[output]
For this implementation, the string "ABC"
has the encoding:
%41%42%43

whats the logic of conversion...


What conversion?

Mar 27 '06 #8
santosh wrote:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
char arr[3] = { 'A', 'B', 'C' };
short cnt;

for(cnt = 0; cnt < 3; cnt++)
printf("%%%x ", arr[cnt]);

fflush(stdout);
This is, unfortunately, not sufficient. To have portably defined
behavior the last line of output must end with an end-of-line character
('\n'). fflush() does not accomplish this. return 0;
}

Mar 27 '06 #9
Martin Ambuhl wrote:
santosh wrote:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
char arr[3] = { 'A', 'B', 'C' };
short cnt;

for(cnt = 0; cnt < 3; cnt++)
printf("%%%x ", arr[cnt]);

fflush(stdout);


This is, unfortunately, not sufficient. To have portably defined
behavior the last line of output must end with an end-of-line character
('\n'). fflush() does not accomplish this.


Is a NL sequence needed at the end of every invocation of an output
function or is one after a sequence, (possibly interleaved with other
statements), of such calls sufficient?

Mar 27 '06 #10
santosh wrote:
Martin Ambuhl wrote:
santosh wrote:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
char arr[3] = { 'A', 'B', 'C' };
short cnt;

for(cnt = 0; cnt < 3; cnt++)
printf("%%%x ", arr[cnt]);

fflush(stdout);


This is, unfortunately, not sufficient. To have portably defined
behavior the last line of output must end with an end-of-line character
('\n'). fflush() does not accomplish this.

Is a NL sequence needed at the end of every invocation of an output
function or is one after a sequence, (possibly interleaved with other
statements), of such calls sufficient?


Just exactly what I said: "To have portably defined
behavior the last line of output must end with an end-of-line character
('\n')." The last line is not "every invocation."

Mar 27 '06 #11
"santosh" <sa*********@gmail.com> writes:
sa*****@yahoo.co.in wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

whats the logic of conversion...


#include <stdio.h>
#include <stdlib.h>

int main(void) {
char arr[3] = { 'A', 'B', 'C' };
short cnt;

for(cnt = 0; cnt < 3; cnt++)
printf("%%%x ", arr[cnt]);

fflush(stdout);
return 0;
}


You don't use anything from <stdlib.h>.

That prints the hexadecimal values rather than converting them, but
the original problem statement wasn't very clear so it's probably ok.
(Converting to a string would require some moderately complex memory
management.)

For characters with values less than 16, you print a single digit,
e.g., "%f" rather than "%f". Again, the problem statement wasn't
clear on this point.

You print a spaces between the characters, which is inconsistent with
the example.

Why do you use type short for the array index? It typically saves
only an insigificant amount of data space, and the resulting code
could be larger and slower on many systems. Just use int.

The "%x" format expects an unsigned int; you're giving it a char.
It's likely to work anyway, but it could cause problems -- and proving
that it does what you want is a lot more work than just fixing the
code. This is one of those rare cases where a cast is actually
appropriate.

3 is a magic number (not a huge deal in a snippet like this).

The output isn't terminated by a new-line, so it's not guaranteed to
appear even with the fflush(stdout) (and the standard is unclear on
just what can go wrong).

#include <stdio.h>
int main(void)
{
char arr[3] = { 'A', 'B', 'C' };
const int arr_len = sizeof(arr) / sizeof(arr[0]);
int i;

for (i = 0; i < arr_len; i++) {
printf("%%%02x", (unsigned int)arr[i]);
}
putchar('\n');
return 0;
}

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 27 '06 #12
"Richard G. Riley" <rg****@gmail.com> writes:
On 2006-03-27, sa*****@yahoo.co.in <sa*****@yahoo.co.in> wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

whats the logic of conversion...

1) learn how to step along a string e.g

for(int i=0;i<strlen(s);i++)
char myChar = s[i];


That re-evaluates strlen(s) on each iteration, making the loop
O(N**2) rather than O(N).

Declaring a variable in a for loop is a new feature in C99; not all
compilers support it.
2) look up in the c reference how to convert values using programs
like printf and sprintf.
Functions, not "programs".
3) look up the "%.1s" type format specifier for printf/sprintf
It prints the first character of the corresponding string argument.
It's simpler just to pass the character itself and use "%c" -- or to
use putchar(). Even so, I don't see how that would be useful in this
context.
good luck!


Indeed.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 27 '06 #13
On 2006-03-27, santosh <sa*********@gmail.com> wrote:
Martin Ambuhl wrote:
santosh wrote:
>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(void) {
> char arr[3] = { 'A', 'B', 'C' };
> short cnt;
>
> for(cnt = 0; cnt < 3; cnt++)
> printf("%%%x ", arr[cnt]);
>
> fflush(stdout);


This is, unfortunately, not sufficient. To have portably defined
behavior the last line of output must end with an end-of-line character
('\n'). fflush() does not accomplish this.


Is a NL sequence needed at the end of every invocation of an output
function or is one after a sequence, (possibly interleaved with other
statements), of such calls sufficient?


It's needed before the end of all output (that is, before the file is
closed or the program exits) to a text stream.
Mar 27 '06 #14

"Martin Ambuhl" <ma*****@earthlink.net> wrote in message
news:Sj******************@newsread1.news.atl.earth link.net...
sa*****@yahoo.co.in wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

#include <stdio.h>
int main(void)
{
unsigned char src[] = "ABC", *t;
printf("For this implementation, the string \"%s\"\n"
"has the encoding: \n", src);
for (t = src; *t; t++)
printf("%%%x", *t);
putchar('\n');
return 0;
}

[output]
For this implementation, the string "ABC"
has the encoding:
%41%42%43

whats the logic of conversion...


What conversion?


Martin, _fix_ your quoting. You merged your reply with to Santosh's
unquoted statements. You're missing Santosh's message header.

Mar 27 '06 #15
On 2006-03-27, Keith Thompson <ks***@mib.org> wrote:
"Richard G. Riley" <rg****@gmail.com> writes:
On 2006-03-27, sa*****@yahoo.co.in <sa*****@yahoo.co.in> wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

whats the logic of conversion...

1) learn how to step along a string e.g

for(int i=0;i<strlen(s);i++)
char myChar = s[i];


That re-evaluates strlen(s) on each iteration, making the loop
O(N**2) rather than O(N).


While any decent compiler ...., you're right. How about i=0;s[i];i++?
Declaring a variable in a for loop is a new feature in C99; not all
compilers support it.
Many do even without full c99 support, though, mainly as a consequence
of also being C++ compilers. The same applies to //comments, though
those are bad in code to be posted on this group for other reasons.
2) look up in the c reference how to convert values using programs
like printf and sprintf.


Functions, not "programs".


potato, potato.
3) look up the "%.1s" type format specifier for printf/sprintf


It prints the first character of the corresponding string argument.
It's simpler just to pass the character itself and use "%c" -- or to
use putchar(). Even so, I don't see how that would be useful in this
context.
good luck!


Indeed.


For extra credit, modify your program to do URL encoding, that is,
encode only characters that need escaping (which ones need to be escaped
is left as an exercise for the reader) and encode 040 as '+'.
Mar 27 '06 #16
"santosh" <sa*********@gmail.com> writes:
Martin Ambuhl wrote:
santosh wrote:
>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(void) {
> char arr[3] = { 'A', 'B', 'C' };
> short cnt;
>
> for(cnt = 0; cnt < 3; cnt++)
> printf("%%%x ", arr[cnt]);
>
> fflush(stdout);


This is, unfortunately, not sufficient. To have portably defined
behavior the last line of output must end with an end-of-line character
('\n'). fflush() does not accomplish this.


Is a NL sequence needed at the end of every invocation of an output
function or is one after a sequence, (possibly interleaved with other
statements), of such calls sufficient?


The new-line is required at the end of the last line of output, before
the file is closed. For stdout, this means before your program
terminates (or before you close stdout explicitly, but you probably
don't want to do that).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 27 '06 #17
Rod Pemberton schrieb:
"Martin Ambuhl" <ma*****@earthlink.net> wrote in message
news:Sj******************@newsread1.news.atl.earth link.net...
sa*****@yahoo.co.in wrote:
[snip!] Martin, _fix_ your quoting. You merged your reply with to Santosh's
unquoted statements. You're missing Santosh's message header.


Martin Ambuhl's post is a direct answer to the OP as can
be seen from the message headers. santosh was never in
between here. You probably mixed that up with another
subthread.

-Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 27 '06 #18
"Rod Pemberton" <do*********@sorry.bitbuck.cmm> writes:
[...]
Martin, _fix_ your quoting. You merged your reply with to Santosh's
unquoted statements. You're missing Santosh's message header.


No, Martin wasn't replying to santosh and didn't quote anything he
said.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 27 '06 #19
Jordan Abel <ra*******@gmail.com> writes:
On 2006-03-27, Keith Thompson <ks***@mib.org> wrote:
"Richard G. Riley" <rg****@gmail.com> writes: [...]
for(int i=0;i<strlen(s);i++)
char myChar = s[i];


That re-evaluates strlen(s) on each iteration, making the loop
O(N**2) rather than O(N).


While any decent compiler ...., you're right. How about i=0;s[i];i++?


Sure (though I'd write "s[i] != '\0'"), or use a pointer, or compute
strlen() outside the loop. (The latter does a single unnecessary
traversal of the string, which isn't nearly as bad as doing N
unnecessary traversals.)
Declaring a variable in a for loop is a new feature in C99; not all
compilers support it.


Many do even without full c99 support, though, mainly as a consequence
of also being C++ compilers. The same applies to //comments, though
those are bad in code to be posted on this group for other reasons.


Many != All. Using C99-specific feature, even ones that are widely
implemented, limits the portability of your code. If you're willing
to accept that, that's fine, but you should be aware of it, and you
should know how to avoid the problem if you need to (in this case, by
declaring the variable separately).
2) look up in the c reference how to convert values using programs
like printf and sprintf.


Functions, not "programs".


potato, potato.


Would you rather call printf and sprintf "potatoes"?

The word "program" has a specific meaning. If you use the words
interchangeably, how are you going to explain the difference between
exit() and return when used outside main()? Using words correctly is
important, especially when communicating with newbies.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 27 '06 #20
On 27 Mar 2006 19:57:27 GMT, in comp.lang.c , Jordan Abel
<ra*******@gmail.com> wrote:
On 2006-03-27, Keith Thompson <ks***@mib.org> wrote:

Functions, not "programs".


potato, potato.


More like potatoe, potato, Mr Vice President.

Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Mar 27 '06 #21

"Michael Mair" <Mi**********@invalid.invalid> wrote in message
news:48************@individual.net...
Rod Pemberton schrieb:
"Martin Ambuhl" <ma*****@earthlink.net> wrote in message
news:Sj******************@newsread1.news.atl.earth link.net...
sa*****@yahoo.co.in wrote:

[snip!]
Martin, _fix_ your quoting. You merged your reply with to Santosh's
unquoted statements. You're missing Santosh's message header.


Martin Ambuhl's post is a direct answer to the OP as can
be seen from the message headers. santosh was never in
between here. You probably mixed that up with another
subthread.


Sorry, it appears there is something wrong with the server I'm connected to.
I'll start cross checking with another for a while.
Mar 27 '06 #22
Keith Thompson wrote:
"santosh" <sa*********@gmail.com> writes:
sa*****@yahoo.co.in wrote:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...

whats the logic of conversion...
#include <stdio.h>
#include <stdlib.h>

int main(void) {
char arr[3] = { 'A', 'B', 'C' };
short cnt;

for(cnt = 0; cnt < 3; cnt++)
printf("%%%x ", arr[cnt]);

fflush(stdout);
return 0;
}


You don't use anything from <stdlib.h>.


I thought, obviously wrongly, that fflush() was declared in stdlib.h
That prints the hexadecimal values rather than converting them, but
the original problem statement wasn't very clear so it's probably ok.
(Converting to a string would require some moderately complex memory
management.)
And I felt that an array based example would be simpler to understand
for the OP.
For characters with values less than 16, you print a single digit,
e.g., "%f" rather than "%f". Again, the problem statement wasn't
clear on this point.

You print a spaces between the characters, which is inconsistent with
the example.
Yes, I hope the OP can forgive me, modify it as necessary.
Why do you use type short for the array index? It typically saves
only an insigificant amount of data space, and the resulting code
could be larger and slower on many systems. Just use int.
Okay.
The "%x" format expects an unsigned int; you're giving it a char.
It's likely to work anyway, but it could cause problems -- and proving
that it does what you want is a lot more work than just fixing the
code. This is one of those rare cases where a cast is actually
appropriate.
Alternatively, the array could have been declared as unsigned int,
though that would be gratituous waste of memory.
3 is a magic number (not a huge deal in a snippet like this).
Yes. Should have coded it cleaner.
The output isn't terminated by a new-line, so it's not guaranteed to
appear even with the fflush(stdout) (and the standard is unclear on
just what can go wrong).
I was thus far under the impression that fflush(stdout) was equivalent,
(in terms of writing buffered output), to a newline character. If
fflush(stdout) is not guaranteed to do it's job, then why define it,
atleast for stdout?
#include <stdio.h>
int main(void)
{
char arr[3] = { 'A', 'B', 'C' };
const int arr_len = sizeof(arr) / sizeof(arr[0]);
int i;

for (i = 0; i < arr_len; i++) {
printf("%%%02x", (unsigned int)arr[i]);
}
putchar('\n');
return 0;
}


Thanks for this improvement.

Mar 27 '06 #23
"santosh" <sa*********@gmail.com> writes:
Keith Thompson wrote: [...]
The output isn't terminated by a new-line, so it's not guaranteed to
appear even with the fflush(stdout) (and the standard is unclear on
just what can go wrong).


I was thus far under the impression that fflush(stdout) was equivalent,
(in terms of writing buffered output), to a newline character. If
fflush(stdout) is not guaranteed to do it's job, then why define it,
atleast for stdout?


Here's what the standard says:

A text stream is an ordered sequence of characters composed into
lines, each line consisting of zero or more characters plus a
terminating new-line character. Whether the last line requires a
terminating new-line character is implementation-defined.

And here's the description of fflush():

If stream points to an output stream or an update stream in which
the most recent operation was not input, the fflush function
causes any unwritten data for that stream to be delivered to the
host environment to be written to the file; otherwise, the
behavior is undefined.

fflush() will cause a partial line to be written to the output file
(or at least "the host environment to be written to the file", which
may not be the same thing), but if the file is then closed without a
new-line, you could still have an ill-formed text file.

Closing a file flushes it anyway, so an fflush() just before the end
of the program doesn't do any good.

fflush() is commonly used when you want to make sure that your output
appears. For example:

printf("Here's a prompt: ");
fflush(stdout);
fgets(answer);

Without the fflush() the prompt won't necessarily appear in time to be
useful. Another example:

fprintf(LOG_FILE, "About to do something dangerous\n");
fflush(LOG_FILE);
do_something_dangerous();

Here, if do_something_dangerous() causes the program to crash badly
enough, the message might never be written. <OT>It can also ensure
that the message will be visible to another process.</OT>

None of this is really guaranteed, since there can still be additional
layers of buffering in the operating system.
Thanks for this improvement.


No problem.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 27 '06 #24
On 2006-03-27, Keith Thompson <ks***@mib.org> wrote:
Jordan Abel <ra*******@gmail.com> writes:
On 2006-03-27, Keith Thompson <ks***@mib.org> wrote:
"Richard G. Riley" <rg****@gmail.com> writes: [...] for(int i=0;i<strlen(s);i++)
char myChar = s[i];

That re-evaluates strlen(s) on each iteration, making the loop
O(N**2) rather than O(N).


While any decent compiler ...., you're right. How about i=0;s[i];i++?


Sure (though I'd write "s[i] != '\0'"), or use a pointer, or compute
strlen() outside the loop. (The latter does a single unnecessary
traversal of the string, which isn't nearly as bad as doing N
unnecessary traversals.)
Declaring a variable in a for loop is a new feature in C99; not all
compilers support it.


Many do even without full c99 support, though, mainly as a consequence
of also being C++ compilers. The same applies to //comments, though
those are bad in code to be posted on this group for other reasons.


Many != All. Using C99-specific feature, even ones that are widely
implemented, limits the portability of your code. If you're willing
to accept that, that's fine, but you should be aware of it, and you
should know how to avoid the problem if you need to (in this case, by
declaring the variable separately).
2) look up in the c reference how to convert values using programs
like printf and sprintf.

Functions, not "programs".


potato, potato.


Would you rather call printf and sprintf "potatoes"?


"potato, potato" is pronounced as /p@teIto p@tAto/ i.e. "ay" and "ah"
sounds for the 'a'.

And I was joking, of course there's a different. There are also
differences between functions and subroutines, but we call them all
'functions', even the ones that aren't.
Mar 27 '06 #25
On 2006-03-27, Mark McIntyre <ma**********@spamcop.net> wrote:
On 27 Mar 2006 19:57:27 GMT, in comp.lang.c , Jordan Abel
<ra*******@gmail.com> wrote:
On 2006-03-27, Keith Thompson <ks***@mib.org> wrote:

Functions, not "programs".


potato, potato.


More like potatoe, potato, Mr Vice President.


I was thinking of "potayto potahto" :P
Mar 27 '06 #26
Jordan Abel <ra*******@gmail.com> writes:
On 2006-03-27, Keith Thompson <ks***@mib.org> wrote:
Jordan Abel <ra*******@gmail.com> writes:
On 2006-03-27, Keith Thompson <ks***@mib.org> wrote:
"Richard G. Riley" <rg****@gmail.com> writes: [...]> 2) look up in the c reference how to convert values using programs
> like printf and sprintf.

Functions, not "programs".

potato, potato.


Would you rather call printf and sprintf "potatoes"?


"potato, potato" is pronounced as /p@teIto p@tAto/ i.e. "ay" and "ah"
sounds for the 'a'.

And I was joking, of course there's a different. There are also
differences between functions and subroutines, but we call them all
'functions', even the ones that aren't.


Yeah, I got the joke. The point of the joke is that there's no
practical difference between "potayto" and "potahto". There's a very
real difference between "function" and "program" (and the C standard
doesn't even use the word "subroutine".)

What exactly was your point?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 27 '06 #27
Keith Thompson wrote:
Jordan Abel <ra*******@gmail.com> writes:
On 2006-03-27, Keith Thompson <ks***@mib.org> wrote:
Jordan Abel <ra*******@gmail.com> writes:
"potato, potato" is pronounced as /p@teIto p@tAto/ i.e. "ay" and
"ah" sounds for the 'a'.

And I was joking, of course there's a different. There are also
differences between functions and subroutines, but we call them all
'functions', even the ones that aren't.


Yeah, I got the joke. The point of the joke is that there's no
practical difference between "potayto" and "potahto". There's a very
real difference between "function" and "program" (and the C standard
doesn't even use the word "subroutine".)

What exactly was your point?

Let's call the whole thing off.

Well, somebody had to do it.


Brian

Mar 28 '06 #28

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sam Smith | last post by:
Hi, I wan't a function to take a const char*, a start bit position and number of bits and convert that bit-stream into a primitive of desired type. I.e. something like: char convert(const...
4
by: Vijai Kalyan | last post by:
I wrote the following function as a curiosity: template<typename SourceType, typename DestinationType> DestinationType NumericCast(const SourceType& value) { std::wstringstream strbuf; strbuf...
7
by: Abhishek Jha | last post by:
How can we write a shortest program in c to convert given number to words format. example input 5012 Output: five thousand tewlve.
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
19
by: caramel | last post by:
i've been working on this program forever! now i'm stuck and going insane because i keep getting a syntax error msg and i just can't see what the compiler is signaling to! #include <stdio.h>...
65
by: kyle.tk | last post by:
I am trying to write a function to convert an ipv4 address that is held in the string char *ip to its long value equivalent. Here is what I have right now, but I can't seem to get it to work. ...
8
by: manmit.walia | last post by:
Hello Everyone, Long time ago, I posted a small problem I had about converting a VB6 program to C#. Well with the help with everyone I got it converted. But I overlooked something and don't...
12
by: Nezhate | last post by:
Hi There, I'm writing a program that takes a decimal number and returns it's binary equivalent. the problem is that I don't know how to return (from function) the binary value as an array of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.