473,385 Members | 1,707 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,385 software developers and data experts.

C/C++ char pointer question

I need some help with the following C/C++ question.
It is fairly straight forward but I'm having some
difficulties.
Thanks for your help.

You are given the following function signature:

void addParen(char* str)

Write code for the function body that will enclose every
character of str with open and close parenthesis. For
example: "Hello!" will change to "(H)(e)(l)(l)(o)(!)".

Feb 13 '06 #1
31 6184

t-tocs wrote:
I need some help with the following C/C++ question.
It is fairly straight forward but I'm having some
difficulties.
Thanks for your help.

You are given the following function signature:

void addParen(char* str)
Is there a good reason why that can't be

void addParen(const std::string& str)

arrays of char are a low level hack to represent strings. Often
std::string is superior.
Write code for the function body that will enclose every
character of str with open and close parenthesis. For
example: "Hello!" will change to "(H)(e)(l)(l)(o)(!)".


What difficulties are you having? Post your code, following the
guidelines here

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

and you will get plenty of help.

The way you've worded your question makes it sound a lot like homework.
If that's true, bear in mind that you won't find many people here
prepared to do your work for you, but you will get the help you need if
you show what you've done and explain what it is you are having trouble
with.

Gavin Deane

Feb 14 '06 #2
Gavin Deane wrote:
t-tocs wrote:
I need some help with the following C/C++ question.
It is fairly straight forward but I'm having some
difficulties.
Thanks for your help.

You are given the following function signature:

void addParen(char* str)


Is there a good reason why that can't be

void addParen(const std::string& str)


I think so :P

try:

std::string addParen(const std::string& str)
or
void addParen(std::string& str)

:)

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Feb 14 '06 #3
In article <11**********************@g43g2000cwa.googlegroups .com>,
"t-tocs" <sc********@gmail.com> wrote:
I need some help with the following C/C++ question.
It is fairly straight forward but I'm having some
difficulties.
Thanks for your help.

You are given the following function signature:

void addParen(char* str)

Write code for the function body that will enclose every
character of str with open and close parenthesis. For
example: "Hello!" will change to "(H)(e)(l)(l)(o)(!)".


I would first complain. How much memory has been allocated to the str
being passed in? What if it can't handle all the extra characters I need
to add to it? It's a very dangerous function signature.

that said, you need to set up some tests:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void addParen(char* str)
{
// put your code here
}

void test_addParen( const string& input, const string& expected ) {
std::vector<char> str( input.size() * 3 + 1 );
copy( input.begin(), input.end(), str.begin() );

addParen( &str[0] );

if ( expected != &str[0] ) {
cout << "Failed test for input '" << input
<< "': expected '" << expected
<< "' but got '" << &str[0] << "'\n";
throw -1;
}
}

int main()
{
test_addParen( "a", "(a)" );
test_addParen( "b", "(b)" );
test_addParen( "ab", "(a)(b)" );
test_addParen( "Hello!", "(H)(e)(l)(l)(o)(!)" );
std::printf( "working\n" );
}

Run the above until it outputs "working". If you are having trouble with
something, show us what you have so far in the "addParen(char*)"
function and what the error is and we'll help you out.
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 14 '06 #4
Can't use string, must use char*.
This is from an phone job interview.
Got around 90% of the questions correct except this question.

Feb 14 '06 #5
In article <11**********************@z14g2000cwz.googlegroups .com>,
"t-tocs" <sc********@gmail.com> wrote:
Can't use string, must use char*.
This is from an phone job interview.
Got around 90% of the questions correct except this question.


Don't use string for the code inside the function you are trying to
write. Just use it in the test harness... Or don't use it at all. I
originally wrote the harness in pure C, but added the c++ constructs to
remove some duplication.

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 14 '06 #6
xPy
the word "hello" is a char table with four columns, one for each
letter, c++ adds one more column in the end of the word, the charachter
in this column is marked as "char(0)", this helps you definethe length
of the word, you can use this like this

void addparen(char* str)
{int k=0;
while(str[k]!=char(0))
{cout<<"(";
cout<<str[k];
cout<<")";
k++;}
}

or you could use "sizeof str" and use its value in a counter...

Feb 14 '06 #7
This is the code I wrote with the assumption that str is pointing to an
array that is big enough to store the original string and the enclosing
'(' and ')'.

void addParen(char* str)
{
int len = strlen(str);
char *temp = new char[(len*3)+1];

int i=0, j=0;
while(str[i])
{
temp[j++]='(';
temp[j++]=str[i++];
temp[j++]=')';
}

temp[j]='\0';

strcpy(str, temp);
delete[] temp;
}

I tested the code and it works.
But the interviewer was not completely satisfy with my solution.
He mentioned something about segv error and memory leaks (can't
remember exactly what he said).
Anyway, thank you everyone for your help.

Feb 14 '06 #8
t-tocs wrote:
This is the code I wrote with the assumption that str is pointing to an
array that is big enough to store the original string and the enclosing
'(' and ')'.

void addParen(char* str)
{
int len = strlen(str);
char *temp = new char[(len*3)+1];

int i=0, j=0;
while(str[i])
{
temp[j++]='(';
temp[j++]=str[i++];
temp[j++]=')';
}
temp[j]='\0';

This loop is wrong. For "hello", you'd generate "(h)(e)(l)(l)(o)".
Thus the interviewers complaints about segv (overrun).
Should be:

temp[0] = '(';
strcpy(temp+1,str);
strcat(temp,")");

strcpy(str, temp);
delete[] temp;
}
Of course, more exception safe would be to use a vector.

#include <vector>
#include <algorithm>
void addparen(char *str)
{
std::vector<char> v;
const int len = strlen(str);
v.reserve(len + 3);
v.push_back('(');
std::copy(str, str + len, std::back_inserter(v));
v.push_back(')');
v.push_back('\0');
strcpy(str,&v[0]);
}
I tested the code and it works.
But the interviewer was not completely satisfy with my solution.
He mentioned something about segv error and memory leaks (can't
remember exactly what he said).
Anyway, thank you everyone for your help.

Feb 14 '06 #9

Ben Pope wrote:
Gavin Deane wrote:
t-tocs wrote:
I need some help with the following C/C++ question.
It is fairly straight forward but I'm having some
difficulties.
Thanks for your help.

You are given the following function signature:

void addParen(char* str)


Is there a good reason why that can't be

void addParen(const std::string& str)


I think so :P

try:

std::string addParen(const std::string& str)
or
void addParen(std::string& str)

:)


Yeah, I thought that soon after I posted, but not before I'd switched
the computer off. It was late and my brain wasn't working :)

Gavin Deane

Feb 14 '06 #10
In article <11**********************@g14g2000cwa.googlegroups .com>,
"t-tocs" <sc********@gmail.com> wrote:
This is the code I wrote with the assumption that str is pointing to an
array that is big enough to store the original string and the enclosing
'(' and ')'.

void addParen(char* str)
{
int len = strlen(str);
char *temp = new char[(len*3)+1];

int i=0, j=0;
while(str[i])
{
temp[j++]='(';
temp[j++]=str[i++];
temp[j++]=')';
}

temp[j]='\0';

strcpy(str, temp);
delete[] temp;
}

I tested the code and it works.
But the interviewer was not completely satisfy with my solution.
He mentioned something about segv error and memory leaks (can't
remember exactly what he said).
Your code works, there are no memory leaks and the only possibility of
an error is if the str passed in isn't big enough to hold the result.
Did you make sure he knew that you were making that assumption? Without
that assumption, there is no way to write the function AFAICT.

If however he was mistakenly thinking that new could return NULL (like
malloc does) then I could see the segv fault.

I'd contact him again and discuss it with him. Your code is right.

Anyway, thank you everyone for your help.


The function can be written without allocating memory.

void addParen(char* const str)
{
int off = strlen( str ) - 1;
*(str + 3*off + 3) = '\0';
for ( char* p = str + off; p >= str; --p, --off ) {
*( str + 3*off + 2) = ')';
*( str + 3*off + 1) = *p;
*( str + 3*off + 0) = '(';
}
}

But the above is far from elegant. I would go with your code unless
profiling showed that the memory allocation was slowing down the program
too much.

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 14 '06 #11
void addparen(char * str)
{
char * out=new char[strlen(str)*3+1];
char *in=str;
while(*in)
{
*(out++) ='(';
*(out++) =*(in++);
*(out++) =')';
}
*out=0;
strcpy(str,out); // this assumes enough memory has been allocated for
the new string
delete [] out;
}

Feb 14 '06 #12

je****@alphacash.se wrote:
void addparen(char * str)
{
char * out=new char[strlen(str)*3+1];
char *in=str;
while(*in)
{
*(out++) ='(';
*(out++) =*(in++);
*(out++) =')';
}
*out=0;
strcpy(str,out); // this assumes enough memory has been allocated for
the new string
delete [] out;
}


You certainly haven't tested this. There is a memory leak and a far
more severe bug in your program.

/Peter

Feb 14 '06 #13


I'm dissapointed at how many people here did this person's homework for
them -- that isn't why this newsgroup is here.

-Tomás
Feb 14 '06 #14

"Tomas" <NU**@NULL.NULL> wrote in message
news:l0******************@news.indigo.ie...


I'm dissapointed at how many people here did this person's homework for
them -- that isn't why this newsgroup is here.

-Tomas


Later he says it was a "phone interview" question, which he already answered
but which he still had questions about. But I'd be interested in exactly
how he presented his code over the phone...? :-)

-Howard
Feb 14 '06 #15

peter koch wrote:
je****@alphacash.se wrote:
void addparen(char * str)
{
char * out=new char[strlen(str)*3+1];
char *in=str;
while(*in)
{
*(out++) ='(';
*(out++) =*(in++);
*(out++) =')';
}
*out=0;
strcpy(str,out); // this assumes enough memory has been allocated for
the new string
delete [] out;
}


You certainly haven't tested this. There is a memory leak and a far
more severe bug in your program.

/Peter

Please point out the memory leak.
All memory allocated is freed. So... where?

As to the more severe bug, can you please tell me what you mean?

Feb 14 '06 #16
Tomas,

This is not a homework question.
I have posted my solution but I just wanted to clearify if there are
any problems with the solution.
As I said in my previous post, my solution works but the interviewer
commented about segv and memory leaks.

Feb 14 '06 #17
On 2006-02-14, je****@alphacash.se <je****@alphacash.se> wrote:

peter koch wrote:
je****@alphacash.se wrote:
> void addparen(char * str)
> {
> char * out=new char[strlen(str)*3+1];
> char *in=str;
> while(*in)
> {
> *(out++) ='(';
> *(out++) =*(in++);
> *(out++) =')';
> }
> *out=0;
> strcpy(str,out); // this assumes enough memory has been allocated for
> the new string
> delete [] out;
> }
You certainly haven't tested this. There is a memory leak and a far
more severe bug in your program.

/Peter

Please point out the memory leak.
All memory allocated is freed. So... where?


What is out pointing to after the loop? Is it the same address you got
from new?
As to the more severe bug, can you please tell me what you mean?


Your function doesn't do what it's specified to do.

--
Neil Cerutti
Feb 14 '06 #18
* je****@alphacash.se:
peter koch wrote:
je****@alphacash.se wrote:
void addparen(char * str)
{
char * out=new char[strlen(str)*3+1];
char *in=str;
while(*in)
{
*(out++) ='(';
*(out++) =*(in++);
*(out++) =')';
}
*out=0;
strcpy(str,out); // this assumes enough memory has been allocated for
the new string
delete [] out;
}

You certainly haven't tested this. There is a memory leak and a far
more severe bug in your program.

/Peter

Please point out the memory leak.
All memory allocated is freed. So... where?

As to the more severe bug, can you please tell me what you mean?


If he did you would learn a small technical detail (good) but also get
two very dangerous impressions of the development process.

Namely (1) that testing is unnecessary and that others will fix whatever
you do wrong, and (2) that it's okay to code at the lowest possible
level of abstraction.

Instead of asking others to find your bugs, TEST your code, and when you
have found the bug, re-implement the thing using a std::string.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Feb 14 '06 #19
In article <11**********************@z14g2000cwz.googlegroups .com>,
"peter koch" <pe***************@gmail.com> wrote:
je****@alphacash.se wrote:
void addparen(char * str)
{
char * out=new char[strlen(str)*3+1];
char *in=str;
while(*in)
{
*(out++) ='(';
*(out++) =*(in++);
*(out++) =')';
}
*out=0;
strcpy(str,out); // this assumes enough memory has been allocated for
the new string
delete [] out;
}


You certainly haven't tested this. There is a memory leak and a far
more severe bug in your program.


After I spent all that work on the test harness, he should have used
it... :-)

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 14 '06 #20
Don't bother. I can see what you mean. It would be much nicer
however to be factual instead of smug.

Naturally the pointer to the beginning of the memory area must
be preserved and delete and strcpy should work on that pointer, while
work
is being done by another pointer.

I have been participating in this group, for a couple of days now
and I must say this smugnes seems to be the prevailing attitude.
Some seem to really try to explain but many just seem to want to attack
errors.
And so what if this was someones homework? Really. If this person
really wants
to cheat on an exam it will come back and bite him later if he wants to
work in
softwaredevelopment. I can only hope he gets a job for a competing
firm.

Feb 14 '06 #21
In article <11**********************@f14g2000cwb.googlegroups .com>,
"je****@alphacash.se" <je****@alphacash.se> wrote:
peter koch wrote:
je****@alphacash.se wrote:
void addparen(char * str)
{
char * out=new char[strlen(str)*3+1];
char *in=str;
while(*in)
{
*(out++) ='(';
*(out++) =*(in++);
*(out++) =')';
}
*out=0;
strcpy(str,out); // this assumes enough memory has been allocated for
the new string
delete [] out;
}


You certainly haven't tested this. There is a memory leak and a far
more severe bug in your program.

/Peter

Please point out the memory leak.
All memory allocated is freed. So... where?

As to the more severe bug, can you please tell me what you mean?


jesper, I posted a test harness earlier. Use it and see what happens.

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 14 '06 #22

t-tocs wrote:
I tested the code and it works.
But the interviewer was not completely satisfy with my solution.
He mentioned something about segv error and memory leaks (can't
remember exactly what he said).


This occasionally happens in interviews. Some "lead" is given the job
of testing you for technical ability. Sometimes these leads are just
mediocre programmers that got put in charge at a small firm. They
often get stuck in a rut thinking that they know more than they really
do because they are the "lead" programmer. They ask stupid questions
and when your answer doesn't exactly fit what they would do they say it
is wrong...it's an ego thing.

To get a job you really want to impress the other people anyway. HR
will override tech quite often so if you show you are easy going and
would fit well in the company what the tech guy says doesn't have as
much weight. Sometimes this isn't true, but guaranteed if HR objects
you won't be getting the job no matter what. If tech strongly objects
then you are probably screwed, but a program that the tech thinks might
have bugs shouldn't result in that. If the guy expects you to write
bug free code on the spot like that they are an idiot and you don't
want to work for them anyway.

Feb 14 '06 #23
"je****@alphacash.se" <je****@alphacash.se> wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:
Don't bother. I can see what you mean. It would be much nicer
however to be factual instead of smug.
Teach a man to fish vs. giving the man a fish. Encourage people to
develop their own debugging skills vs. handing them the answer on a
silver platter.
Naturally the pointer to the beginning of the memory area must
be preserved and delete and strcpy should work on that pointer, while
work
is being done by another pointer.
If this was a "natural" thing to do, why wasn't it in the code? Since
it's not there, then presumably the person writing the code has made an
error.
I have been participating in this group, for a couple of days now
and I must say this smugnes seems to be the prevailing attitude.
Some seem to really try to explain but many just seem to want to attack
errors.
Um... what you perceive as "attacking errors" are really attention to
detail. Newsflash: programming requires a large amount of attention to
detail. Ever heard of an "off-by-one error"? "We" do not want people
to be getting wrong information, so "we" correct errors.
And so what if this was someones homework? Really. If this person
really wants
to cheat on an exam it will come back and bite him later if he wants to
work in
softwaredevelopment. I can only hope he gets a job for a competing
firm.


Two items:
1) How is this really helping the person in their studies if they are
simply handed the answer.
2) Working for a competing firm isn't the problem. Working in _my_ firm
is. I don't want to have to be forever cleaning up after other people
who don't understand what they're doing.
Feb 14 '06 #24
In article <11**********************@f14g2000cwb.googlegroups .com>,
"je****@alphacash.se" <je****@alphacash.se> wrote:
Don't bother. I can see what you mean. It would be much nicer
however to be factual instead of smug.

I have been participating in this group, for a couple of days now
and I must say this smugnes seems to be the prevailing attitude.
It may be the medium. It's hard not to sound smug when the person you
are 'talking' to can't hear your tone of voice. We wanted to lead you to
the answer, not just give it to you, and that can come off as smugness
sometimes.

And so what if this was someones homework? Really. If this person
really wants
to cheat on an exam it will come back and bite him later if he wants to
work in
softwaredevelopment. I can only hope he gets a job for a competing
firm.


The problem is, he may get the job that you wanted. By all means, do his
homework, you may learn something in the process, but you don't have to
give him the answer. :-) If you want to help him, don't give him the
answer, lead him to it. If you want to hurt him, give him the wrong
answer, or one so obfuscated that he can't learn anything from it.
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 14 '06 #25

Andre Kostur skrev:
"je****@alphacash.se" <je****@alphacash.se> wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:
Don't bother. I can see what you mean. It would be much nicer
however to be factual instead of smug.
Teach a man to fish vs. giving the man a fish. Encourage people to
develop their own debugging skills vs. handing them the answer on a
silver platter.


What made you think I don't "know how to fish" ? I didn't ask the
question.
If this was a "natural" thing to do, why wasn't it in the code? Since
it's not there, then presumably the person writing the code has made an
error.
Yes. But the person who asked the question would have been better
helped
by you pointing out what misstake I made. I did not ask the question
(I can't say this enough). You don't have to
coax me to learn about pointers. I know how to use them. Fluently.
Um... what you perceive as "attacking errors" are really attention to
detail. Newsflash: programming requires a large amount of attention to
detail. Ever heard of an "off-by-one error"? "We" do not want people
to be getting wrong information, so "we" correct errors.
Ever left out a ;? It's the same error. Basically.

If I had been even the slightest curious about how this is really done
I would not have posted an attempt to *answer* the question. The
problem was
and is rudimetary. Basic. I wrote the code blind because the solution
to the problem
was a simple matter of constructing a string, a task that can be
accomplished in
a myriad of ways. For example you could have used std::string like,
someone pointed
out, you could have constructed literals: {"(a)","(b)".. aso. Silly as
hell but it would work.
If you *had corrected* the error it would have been fine.
You didn't however. You pointed out the existance of one, good for you.
Two items:
1) How is this really helping the person in their studies if they are
simply handed the answer.
2) Working for a competing firm isn't the problem. Working in _my_ firm
is. I don't want to have to be forever cleaning up after other people
who don't understand what they're doing.


Exactly right. My point exactly. He wasn't helped. He fooled himself by
getting
someone to do it for him (IF this was infact homework).
If you find it troublesome to fix errors of beginners maybe you should
test
them before hiring them.. I don't know.... Might be a good idea.
As for the comment about abstraction levels (made by Alf I think for
some reason I can't browse the groups at this moment): It's seldom a
good idea to make your solution too
general. In a real project you will sooner or later drown in overhead.
Experience talking here.

Feb 14 '06 #26
This is a test. I'm trying to reply but it doesn't work.

Feb 14 '06 #27
TB
je****@alphacash.se sade:
This is a test. I'm trying to reply but it doesn't work.


There is a purpose for the existence of

alt.test

--
TB @ SWEDEN
Feb 14 '06 #28

Daniel T. skrev:
In article <11**********************@f14g2000cwb.googlegroups .com>,
"je****@alphacash.se" <je****@alphacash.se> wrote:
It may be the medium. It's hard not to sound smug when the person you
are 'talking' to can't hear your tone of voice. We wanted to lead you to
the answer, not just give it to you, and that can come off as smugness
sometimes.

The problem is, he may get the job that you wanted. By all means, do his
homework, you may learn something in the process, but you don't have to
give him the answer. :-) If you want to help him, don't give him the
answer, lead him to it. If you want to hurt him, give him the wrong
answer, or one so obfuscated that he can't learn anything from it.

This is a good post. Thank you for talking sense. :-) (no smugness
intended)

You are right. We might some day compete about the same job. However I
don't feel threatened by someone who can't construct a string without
asking
for help. And cynisism aside he may be telling us the truth and this is
not homework.
The solution he posted is valid. (Have not tested it in a compiler but
the theory is sound)
So maybe he just actually wanted to know if there is something fishy
about it that he
didn't know. Just maybe... (and if there is I am also intessted in
knowing what it is)
The framework I posted (yes with errors) is very similar to the
solution he
posted as his own. And thus my post, arriving after the fact (due to
real work
getting in the way before I could finish the post at the time i began
to write it)
, became absolutly redundant.

Feb 14 '06 #29

TB skrev:
je****@alphacash.se sade:
This is a test. I'm trying to reply but it doesn't work.


There is a purpose for the existence of

alt.test

--
TB @ SWEDEN

OT:
oh my god... You are just too much.
Might do you some good to be a little more understanding and open to
the fact that not everyone has lived their entire life on the usenet.
I return in kind:
There is a purpose for the existence of your backspace key and all
those cancel buttons
in what ever application you posted that piece of horrendous attitude
from.

Feb 14 '06 #30
In article <11*********************@g43g2000cwa.googlegroups. com>,
"je****@alphacash.se" <je****@alphacash.se> wrote:
Daniel T. skrev:
In article <11**********************@f14g2000cwb.googlegroups .com>,
"je****@alphacash.se" <je****@alphacash.se> wrote:
It may be the medium. It's hard not to sound smug when the person you
are 'talking' to can't hear your tone of voice. We wanted to lead you to
the answer, not just give it to you, and that can come off as smugness
sometimes.

The problem is, he may get the job that you wanted. By all means, do his
homework, you may learn something in the process, but you don't have to
give him the answer. :-) If you want to help him, don't give him the
answer, lead him to it. If you want to hurt him, give him the wrong
answer, or one so obfuscated that he can't learn anything from it.

This is a good post. Thank you for talking sense. :-) (no smugness
intended)

You are right. We might some day compete about the same job. However I
don't feel threatened by someone who can't construct a string without
asking
for help. And cynisism aside he may be telling us the truth and this is
not homework.
The solution he posted is valid. (Have not tested it in a compiler but
the theory is sound)
So maybe he just actually wanted to know if there is something fishy
about it that he
didn't know. Just maybe... (and if there is I am also intessted in
knowing what it is)
The framework I posted (yes with errors) is very similar to the
solution he
posted as his own. And thus my post, arriving after the fact (due to
real work
getting in the way before I could finish the post at the time i began
to write it)
, became absolutly redundant.


You inadvertently pointed out another great reason not to give the
answer. You may be wrong. ;-)

I try to never give an answer here unless I've actually tested it, too
embarrassing.

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 14 '06 #31

Daniel T. skrev:
You inadvertently pointed out another great reason not to give the
answer. You may be wrong. ;-)

I try to never give an answer here unless I've actually tested it, too
embarrassing.

hehe :-) Yes.. But even a incorrect answer might be helpful if
delivered in a forum where the faults in such an answer is pointed out
and
corrected.
Really, having to be embarrased for being wrong? Is this good? If
instead of
belittleing (spelling? and don't I mean you) people who are wrong we
work
together to answer questions as put to us, in a friendly fashion,
maybe this is a better way?...

I feel sorry for this community if its members acctually has to, as you
state, be
embarrased for being wrong. Everyone is wrong sometimes.
And if anyone thinks I, am embarrased for being wrong? You are
misstaken. :-)
I am often wrong. In many areas of life.

(I appologize for my poor spelling and my sometimes horrible english)

Feb 14 '06 #32

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

Similar topics

9
by: ambar.shome | last post by:
Hi , Can anyone tell me when should I use char**. Does it have nay extra advantage over char*& ? "strtol" function takes char** as one of its parameters. But,cant understand why that is needed?...
21
by: Bret | last post by:
I'm curious why char** argv is acceptable in the main() declaration. In the comp.lang.c FAQ (question 6.18) it says that pointers to pointers and pointers to an array are not interchangable. ...
1
by: b83503104 | last post by:
When are they not consistent?
5
by: jab3 | last post by:
(again :)) Hello everyone. I'll ask this even at risk of being accused of not researching adequately. My question (before longer reasoning) is: How does declaring (or defining, whatever) a...
1
by: lovecreatesbeauty | last post by:
There is a warning/(error? I remember it is an error for line 10 on some compilers before. At least on g++, it is an error.) for line 10. I first read a similar example from `Expert C Programming...
42
by: S S | last post by:
Hi Everyone I have const char *p = "Hello"; So, here memory is not allocated by C++ compiler for p and hence I cannot access p to modify the contents to "Kello" p = 'K'; // error at runtime
30
by: Yevgen Muntyan | last post by:
Hey, Why is it legal to do union U {unsigned char u; int a;}; union U u; u.a = 1; u.u; I tried to find it in the standard, but I only found that
18
by: william | last post by:
below is a short piece of code I wrote to testify my understanding of char *, and array. #include <stdio.h> int main() { char *str=NULL; char x="today is good!"; printf("%s", str);
9
by: Peithon | last post by:
Hi, This is a very simple question but I couldn't find it in your FAQ. I'm using VC++ and compiling a C program, using the /TC flag. I've got a function for comparing two strings int...
43
by: emyl | last post by:
Hi all, here's an elementary question. Assume I have declared two variables, char *a, **b; I can then give a value to a like a="hello world";
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.