|
I confirmed that gps value changes in NMEAParserDemo Project
Did to do practice moving NMEAParserDemo Project's source to web project as it is
Value 'Ho' does not change.
I teach what did wrongly
NMEAParserDemo
web
|
|
|
|
|
rephrase or hire an interpreter.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
|
Yeah! I have just hired a detective who is helping me in figuring out where is this 'Ho' coming from.
I trust the detective as he is a direct descendant of the Sherlock Holmes dynasty...
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi to All,
Here I am getting an error. Breaking my head but not able to get it done. Please help me out with.
I know I have done some silly mistake,..But not able to view it
Mu code is...
char *a,*b,*temp;
a="aa";
b="bb";
while(*a!='\0')
{
*temp++ = *a++;
}
while(*b!='\0')
{
*temp++ = *b++;
}
*temp = '\0';
....
its showing error in the line...*temp++ = *a++;
Thanks in advance
|
|
|
|
|
What error do you get [Compile/RunTime]. Please provide the details
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Thnaks for your reply
I am getting an runtime error...
(Unhandled exception...Access violation)
Thanks...(anyway,..My brothers name is Anshumaan)
-----------------------------
I am a beginner
|
|
|
|
|
Ah! that may be because temp is not initialized.
Initialize it!
And believe it or not, but my brothers name is HIMANGSHU
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
thanks a lot...
About the name..that's interesting...I feel somewhat to talk personal staff in this forum. Lets not violet the rules..hehe...Could you give me Gmail Id if you dont mind.We can talk in Gtalk .
Regards,
Himangshu
|
|
|
|
|
What error? I cannot see syntactic error there. Do you allocate memory for temp?
|
|
|
|
|
I am getting an runtime error...
(Unhandled exception...Access violation)
|
|
|
|
|
You should must allocate memory for temp .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks
But there is one problem. How much memory should I allocate? Since It is a program for concatenation of string...And I wont be knowing the no of characters after contcatination(ie the size of the temp) in advance.
How to go about it?
|
|
|
|
|
Well you may allocate a predefined amount of memory (on statistical grounds) and then reallocate (for instance, in C language, you may use malloc and realloc ) a bigger size if needed.
BTW: you know, there are C runtime library functions for the purpose of concatenating strings.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
yes But I wanted to implement it with my own code....So that I learn pointer concept too..
-----------------------------
I am a beginner
|
|
|
|
|
I used the following code.....No error but not giving any results
char *a,*b;
char *temp;
temp=new char[5];
a="aa";
b="bb";
while(*a!='\0')
{
*temp++ =*a++ ;
}
while(*b!='\0')
{
*temp++= *b++ ;
}
*temp = '\0';
printf("%s",temp);
-----------------------------
I am a beginner
|
|
|
|
|
That's almost the solution... , try:
char *a,*b;
char *temp, *dest;
dest=new char[5];
temp = dest;
a="aa";
b="bb";
while(*a!='\0')
{
*temp++ =*a++ ;
}
while(*b!='\0')
{
*temp++= *b++ ;
}
*temp = '\0';
printf("%s",dest);
of course you need now to generalize the code (ad remember to free dest when you no longer need it)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Oh thanks a lot...its working fine...
I have to increase my knowledge towards pointer
-----------------------------
I am a beginner
|
|
|
|
|
himangshuS wrote: I wont be knowing the no of characters after contcatination(ie the size of the temp) in advance.
Yes you can - you need to allocate strlen(A) + strlen(B) + 1 characters, where strlen is defined as follows:
int strlen(const char* s)
{
int count;
while (*(s++))
++count;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
A code you have past here is the exact code that is in your system?
But if you have taken temp as array (char temp[XX] ) then you might get error which you told. But a code that we are sawing has no that kind of error.
Do not trust a computer...
Always check what computer is doing
regards,
Divyang Mithaiwala
Software Engineer
modified on Thursday, May 7, 2009 5:38 AM
|
|
|
|
|
Sure?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Divyang Mithaiwala wrote: Because if you have taken temp as array (char temp[XX]) then you might get error
Why so?
Divyang Mithaiwala wrote: But a code that we are sawing has no that kind of error.
Did you trust your computer to check if there was a runtime error?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
sorry, But I really didnot get that
-----------------------------
I am a beginner
|
|
|
|
|
When I was posted I haven't seen your clarification that you are facing run time error (due to no refresh page).
So, If you have taken variable as char temp[10]; and try to execute
*temp++ = *a++;
it will give you compile time error.
Do not trust a computer...
Always check what computer is doing
regards,
Divyang Mithaiwala
Software Engineer
|
|
|
|
|
I haven't tested that nor tried something similar, but I think that the hole think wont give you the right result anyway.
By incrementing the char * temp it jumps to the next position and you will lose the previous position, don't you?
So if you really want to do something like that you should have a pointer to the first position of temp (I guess).
So why not simply allocate mem for temp and then do a memcpy with a and b? Given memcpy temp and for b &temp[2] for example.
I hope this will do the trick, but I am just guessing.
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|