Click here to Skip to main content
15,569,858 members

Comments by leon de boer (Top 62 by date)

leon de boer 3-Mar-17 12:24pm View    
If he isn't doing in place he needs to change his interface so he doesn't commit a C crime against humanity.

int afunction(char *s1, char *s2, char* outbuf)
OR
int afunction(char *s1, char *s2, char* outs1, char* outs2)

Then he still doesn't need the number of pointers he has because the interface defines 4 and he still needs just 1 inside the function to move around as his temporary (I would accept two for a beginner). That is the whole point of the local interface it forces him to set the pointers or it won't compile and he wouldn't be here :-)

That is why this is pretty black and white, once students start playing around with local functions they need to know why that local interface exists. It's not there for good looks, it's there to protect you from doing dangerous things.
leon de boer 3-Mar-17 1:06am View    
It basically has to be in place because he hasn't got access to anything else unless you allow pure stupidity and are going to set the pointer to a global. One would hope they still teach setting a char* pointer to a global is beyond dangerous it is actually stupid and reckless. You would be fired for doing that in my company as it's basic pointer safety 101, because putting an extra pointer on the interface for output is ever so hard.

So I guess if we follow your lead he is doing it all wrong he should have s1 and s2 as globals, heck who needs a local interface its just a waste of time and we end up writing something that looks like GW Basic :-)
leon de boer 28-Jun-16 23:25pm View    
Same thing the errors are syntax from something earlier ... the keyword "unsigned" is known to every C compiler so the compiler parser has essentially crashed. The first error is at line 67, so the problem is in those first 67 lines. Are there any warnings in the earlier lines???

Don't ignore warnings when you have this sort of error you need to deal with the problems in line order. So our question is what is going wrong in the first 66 lines of USART.H that is causing the problem in line 67. Look at any warnings in those early lines and failing all else post me the first 67 lines of USART.H
leon de boer 5-Jun-16 11:29am View    
Look at the function strchr and use it find a whitespace character. When you have them all write the string back out starting from last one first.
leon de boer 5-Jun-16 10:28am View    
I put the solution at the end since you got stuck and are losing heart :-)

There are various ways to do the loops but that is basics and it is important you understand the comments, so you get what you should have done.