16,006,594 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by John R. Shaw (Top 26 by date)
John R. Shaw
16-May-20 12:26pm
View
Technically, that would be number 3. It is what 'toni_1' thought he/she was doing. Coping by value means a copy is passed on the stack, which is what number 3 is doing. What 'toni_1' was doing amounted to passing a pointer to the original array, which means any change to the array in the function would change the original. Number 3 would only change the copy. That is why we need to specify constant variables in our arguments (I tell you where the data is, but you are not allowed to change it).
:) Rubiks - best time 2.54 minutes (now, have no idea).
John R. Shaw
28-Mar-20 1:42am
View
Interesting. But do not post home work questions here. Grab a pencil and paper and figure it out.
-OR-
I could put on a blind fold and see if I could do it.
John R. Shaw
13-Mar-20 13:17pm
View
LMAO! Thanks that's the best laugh I had in weeks.
I am still trying to stop and failing!
John R. Shaw
13-Mar-20 10:42am
View
You are correct :)
But if I did not introduce such mistakes, how would they learn?
John R. Shaw
11-Mar-20 12:23pm
View
And ending brace '}'. Also the weird '"' in the for loop will stop it from compiling.
Good catch on the 'free(p)'; otherwise BOOM!
John R. Shaw
27-Feb-20 5:12am
View
If this was not an academic (home work) question, I would tell the person asking the question to reword it or jump off the nearest bridge. Researching other peoples solutions is not the same as finding your own. You need to break down the question piece by piece and figure it out from there. Other peoples solutions are not the only solution; who knows your untainted solution may be better.
John R. Shaw
9-Jan-20 23:25pm
View
I actually like your solution better than mine. But there is one problem - do not hard code the number of characters in the extension.
A better solution:
return (strcmp(&szFileName[strlen(szFileName) - strlen(szExt), szExt);
John R. Shaw
8-Nov-18 13:26pm
View
Try "while (x < 9 && getline(ss, token, ','))" to start with.
John R. Shaw
30-May-18 15:11pm
View
Do not forget to remove the hard code "saleAmount = 100" and "taxRage = 10". Those are supplied as the parameters to the function.
John R. Shaw
28-May-18 17:41pm
View
Sounds like it is time to break out the paper and pencil. Draw the 2 dimensional array [10x10 grid] with appropriate values, so you can visualize the problem.
John R. Shaw
25-May-18 14:28pm
View
Returning a 'const' breaks normal behavior.
a = b = c; // 'const' or no 'const' this works
(a = b) = c; // is legal, but will not work if assignment operator returns 'const'
Which is why the default assignment operator is specified by the standard to return 'T&' instead of 'const T&'.
John R. Shaw
24-May-18 13:17pm
View
The return type should not be const.
T& T::operator=(const T&)
John R. Shaw
8-Aug-11 23:41pm
View
5 - Good answer. If nothing else has changed, then it will probably be the same address. But, like you said, there is no guarantee.
John R. Shaw
8-Aug-11 23:22pm
View
int* first = &ar[0]; int* last = &ar[10];
range = [first, last)
last marks the end of the range, but is not in the range.
actual range = [first, last-1]
last is no more valid than last+1; it is just the address following the last valid address.
John R. Shaw
23-Jul-11 12:29pm
View
5 - good answer
John R. Shaw
23-Jul-11 12:25pm
View
Sorry 3 - it was a 4 for unneeded 'new' in the loop, but dropped to 3 because it will leak - no 'delete'.
John R. Shaw
18-Jul-11 16:39pm
View
Deleted
Reason for my vote of 5
Nice, clean and simple for beginners. Good job!
John R. Shaw
16-Jul-11 12:13pm
View
Actually they are not obsolete. I know Unicode encoding in depth (bmp, surrogates, etc.) - I have done internationalization. Encoding in Big5 and Traditional Chinese as well as Shift-Jis are still around and need conversion into Unicode. The newer C standard (see Draft N1494) does provide new Unicode specific functions in clause 7.27 and under the hood the STL usually calls the C-functions.
John R. Shaw
15-Jul-11 13:58pm
View
Basically - you do need to create a scan-line list to use the normal method - which relies on knowing the coordinates of the edges.
Example line to fill:
[0][0] = 1, ..., [0][10] = 1, [0][11] = 1, [0][12] = 1
in MyPoint list that would be
list[0] = {0,0}; // left
list[1] = {0,10}; // right
In this case we do not want [0][11] or [0][12] in our list.
The method you are currently using would work, but resembles a flood fill. May be a look at the diagrams in my QuickFill article at codeproject would give you a better idea.
John R. Shaw
15-Jul-11 13:32pm
View
Cool! Thanks for the link. It looks like you found what you were looking for.
John R. Shaw
15-Jul-11 12:42pm
View
Not exactly, but there are lots of java libraries out there - try search for "java statechart".
I found this http://sourceforge.net/projects/state4j/
John R. Shaw
15-Jul-11 9:53am
View
Doh! Thanks :D
John R. Shaw
14-Jul-11 21:20pm
View
In your example - you could simply make the array "static int arr[10]" - as long as it is not changed by the next call to the function, there is no problem.
If you are going to allocate memory, then you might as well use vector. To avoid copy on return - pass a reference to a vector as an argument - it's more efficient.
John R. Shaw
14-Jul-11 21:04pm
View
Read the question. Christian has it right. The question was "I am not getting any error why?". In other words, why was there no error when accessing the array after it was popped off the stack [deleted].
John R. Shaw
14-Jul-11 20:53pm
View
I give - it insist on adding </vector> to the end - I the rest looks fixed.
John R. Shaw
13-Jul-11 18:06pm
View
Strange I do not see what strcpy has to do with the question. But the while loop would be more efficient.
Show More