9,868,710 members (30,684 online)
Visit CodeProject.TV
Discuss CodeProject.TV
Sign in
Email
Password
Forgot your password?
Sign in using
home
articles
Chapters and Sections
>
Search
Latest Articles
Latest Tips/Tricks
Top Articles
Beginner Articles
Technical Blogs
Posting/Update Guidelines
Article Help Forum
Article Competition
Submit an article or tip
Post your Blog
quick answers
Ask a Question
View Unanswered Questions
View All Questions...
C# questions
ASP.NET questions
VB.NET questions
C#4.0 questions
C++ questions
discussions
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work & Training Issues
Design and Architecture
ASP.NET
JavaScript
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
Adobe Technologies
C#
Free Tools
Objective-C
Ruby On Rails
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
.NET Framework
Mobile
VS 11 & .NET 4.5
Sharepoint
Silverlight / WPF
Visual Basic
Web Development
Site Bugs / Suggestions
features
Component & Service Catalog
Competitions
News
The Insider Newsletter
Newsletter archive
Surveys
Product Showcase
Research Library
CodeProject Stuff
community
The Insider News
The Lounge
The Weird & The Wonderful
The Soapbox
Press Releases
Who's Who
Most Valuable Professionals
Company Listings
Non-English Language
>
General Indian Topics
General Chinese Topics
help
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
Site Map
Advertise with us
Employment Opportunities
About Us
The default search term operator is
AND
.
You can use brackets,
AND
,
OR
, and
NOT
to improve your search. For example:
C# AND NOT(VB or SQL)
A query of a single
*
will return everything, filtered by any filters.
Filter examples:
Search by Author
author:"author name"
Filter by tag
tag:C#
or
tag:(C++ or Java)
Wildcard search
use "?" or "*" eg.
gr?d
or
gr*
74 Results
Search
Everything
Articles
Technical Blogs
Tips & Tricks
Questions
Answers
Forum Messages
News Items
Catalog Items
Videos
Training Courses
Just My Stuff
My Bookmarks
Sort by
Relevance
Rating Asc
Rating Desc
Title Asc
Title Desc
Author Asc
Author Desc
Date Created Asc
Date Created Desc
Date Modified Asc
Date Modified Desc
Price Asc
Price Desc
Duration Asc
Duration Desc
Match
All Fields
Title
Description
Author(s)
Tags
Any Date
Last 12 hours
Last 24 hours
Last week
Last 2 weeks
Last month
Last 3 months
Last 6 months
Last year
January
February
March
April
May
June
July
August
September
October
November
December
Rating Range
All - Including Unrated
1.0 - 5.0
2.0 - 5.0
3.0 - 5.0
4.0 - 5.0
4.5 - 5.0
4.8 - 5.0
5.0
Advanced Filters:
Article Topics
All Topics
Desktop Development
Web Development
Mobile Development
Cloud Computing
Enterprise Systems
Database
Multimedia
Languages
Platforms, Frameworks & Libraries
General Programming
Graphics / Design
Development Lifecycle
General Reading
Third Party Products
Mentor Resources
Article License
All Licenses
CPOL
CDDL
Ms-PL
MPL
CPL
Eclipse
MIT
BSD
Apache
CC (ASA 2.5)
Zlib
Public Domain
CC (Attr 3U)
CC (ASA 3U)
LGPL3
GPL3
Forums
All Forums
Feature Forums
General Programming
Web Development
Product Lifecycle
Database & SysAdmin
General Discussions
Non-English Language
Catalog Category
All Categories
Books & Training
Charting & Graphing
Components, Controls, Libraries
Data Manipulation & Mining
Database Tools
Debugging
Documentation & Help
Financial, Math & Scientific
Frameworks & APIs
General Development Tools
GIS & Maps
Graphics & 3D Modeling
Hardware and Robotics
Hosting
IDEs
Imaging
Mobility
Multimedia
Networking
Performance and Profiling
Programming Languages
Project Life-cycle Management (ALM)
Reporting
Search
Security
Setup & Deploy
System Adminstration
Utilities
Virtualization
Web Design/Development
Catalog License
All Licenses
Commercial
Fully Function Evaluation version
Limited Functionality Trial
Limited Time Trial
Shareware
Free For Personal Use
Freeware
Page 1 of 2
Page Size:
10
·
25
·
50
Author filtered by: Ian A Davidson
[x]
binary read mode code not working
by
Ian A Davidson
Answer
14 May 2013
license:
CPOL
You're opening the file with ios:ate so that the file pointer is at the end of the file, which is why tellg returns you the size you need. You then need to reset the pointer to the start of the file, using seekg, before you call read.Regards,Ian.
General Programming
»
Uncategorised Quick Answers
»
General
C++
VC++
Help to findout Week number of year?
by
Ian A Davidson
Answer
13 May 2013
license:
CPOL
I believe the calculation is to take the day of the year, subtract the day of the week add seven and then divide by seven and add one:int week = int((yday - wday + 7) / 7) + 1You might have to adjust this depending on whether you want the week to start on Sunday or Monday (Sunday is more...
General Programming
»
Uncategorised Quick Answers
»
General
C++
C
VC++
MFC/C++
Reading Executible path from Registry
by
Ian A Davidson
Answer
13 May 2013
license:
CPOL
The (Default) value is special. To retrieve it, specify either an empty string ("") or null:string path = (string)acroPath.GetValue(null);That should solve the problem you've asked about.A few other tips:1) You don't need to open each individual subkey in turn - you can specify...
General Programming
»
Uncategorised Quick Answers
»
General
C#
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
by
Ian A Davidson
Answer
12 May 2013
license:
CPOL
1) Do you ever add any objects to the "MyData" ArrayList (_sharedData)?2) You should check that "cvData" in your MyData method is not null and that it has elements.A few other weird points with this code (bearing in mind that obviously there is a great deal not included in the question...
General Programming
»
Uncategorised Quick Answers
»
General
C#
How can i access the last node in this linked list.Last node is not reachable due to unsatisfied condition inside last while loop.Please suggest some solutions to it
by
Ian A Davidson
Answer
11 May 2013
license:
CPOL
Try this instead:int pos = 0;int flag = 0;node* ptr = start;while(ptr != NULL){ if(ptr->info == item) { flag = 1; break; } else { ++pos; ptr = ptr->next; }}Ian.
General Programming
»
Uncategorised Quick Answers
»
General
C
Using Rand() to get an 8 digit random number in C++
by
Ian A Davidson
Answer
11 May 2013
license:
CPOL
You need to think more about your code!1. "rand()" returns a pseudo-random (i.e. any number) between 0 and RAND_MAX (32767). Unless you format the value to 8 digits by zero padding, the output could be any length from 1 to 5 digits.2. Using mod 99999999 means that you end up with the same...
General Programming
»
Uncategorised Quick Answers
»
General
C++
Is there any logical error in this linked list insertion code.please help
by
Ian A Davidson
Answer
11 May 2013
license:
CPOL
Yes there is. And it's is unclear what you are trying to do (where are you trying to insert the new node?). Here are three options:// If you are trying to insert a new node at the end of the linked list:// e.g. you have [start][node a][node b]// ptr = any node in the list; insert node...
General Programming
»
Uncategorised Quick Answers
»
General
C
Image processing in C++
by
Ian A Davidson
Answer
11 May 2013
license:
CPOL
If it's for Windows you might take a look at GDI+[^]Regards,Ian.
General Programming
»
Uncategorised Quick Answers
»
General
C++
ImageProcessing
Problem with reading and writing of \n charecter
by
Ian A Davidson
Answer
10 May 2013
license:
CPOL
As has already been said, Windows Notepad expects a carriage return-line feed pair (\r\n). There is, however, no other reason to stick to this out-dated method of ending a line (invented due to the slowness of the tele-type machine of the day) but you do need to know about it for reading text...
General Programming
»
Uncategorised Quick Answers
»
General
C++
Win32
Some help and tip for MFC project!!
by
Ian A Davidson
Answer
10 May 2013
license:
CPOL
Does it have to be C++? How about C#? Since you would have to "learn MFC", I can't see it would be much harder to "learn .NET", and you'll find it a lot easier and quicker to produce a decent application :)Regards,Ian.
General Programming
»
Uncategorised Quick Answers
»
General
MFC
Exe runs properly in debug and crash in release
by
Ian A Davidson
Answer
10 May 2013
license:
CPOL
There are some major differences with the way memory is laid out in debug and release compiled applications. Because of this, there is more scope for overrun and underrun. However, if you have all the checks switched on, I would expect some sort of assertion error in this case (though the...
General Programming
»
Uncategorised Quick Answers
»
General
VC6
C++
C++
Debugging
VC++
release
how to use ReadPrivateProfileString.
by
Ian A Davidson
Answer
9 May 2013
license:
CPOL
Hi Uday,First of all, as far as I'm aware there is no such function as ReadPrivateProfileString. The function is GetPrivateProfileString.Secondly, both that function and WritePrivateProfileString, as MSDN says, are "provided only for compatibility with 16-bit Windows-based applications." ...
General Programming
»
Uncategorised Quick Answers
»
General
C++/CLI
MFC
VC++
Code works perfect i chrome but not in fire fox?
by
Ian A Davidson
Answer
8 May 2013
license:
CPOL
Hi Abdul(?),My suggestion is to first validate your page with w3.org's validators and fix all the errors listed, and see if that solves the problem.Validate your XHTML here: http://validator.w3.org/[^]Validate the CSS here: http://jigsaw.w3.org/css-validator/[^]You actually...
General Programming
»
Uncategorised Quick Answers
»
General
CSS
HTML
Install log - date and time on each line?
by
Ian A Davidson
Question
8 May 2013
license:
CPOL
Hi all,I have a C# assembly which installs itself using AssemblyInstaller (and some other Installer-derived classes).I've had a request to modify the log file to the date and time "against each line" in the log file.The problem is that the log file is automatically generated. I can...
General Programming
»
Uncategorised Quick Answers
»
General
C#
installer
Global functions vs. object orientation
by
Ian A Davidson
Answer
7 May 2013
license:
CPOL
1) It sounds like your object model may be wrong, which would be why "OO is broken". I would check that in the first instance.With respect to how the "problem" would be solved in C#:2) As lukeer has suggested, you could create a static method in a class, possibly a static class, related...
General Programming
»
Uncategorised Quick Answers
»
General
C++
C#
OOP
Replacing CRLF with a blank space if it occurs within a line
by
Ian A Davidson
Answer
5 May 2013
license:
CPOL
As you are reading the file in, you will need to check whether you are reading characters that are inside a quoted string (e.g. a boolean indicating whether you have found a quote mark) and if so, keep certain characters, such as and , in the string.When you reach a or character that is not...
General Programming
»
Uncategorised Quick Answers
»
General
C#
how to use member variables in another class
by
Ian A Davidson
Answer
5 May 2013
license:
CPOL
In the first place, don't access member variables of other classes directly. This is very bad practice. Your member variables should be private and you should declare methods (functions) to return the value. This prevents a caller from setting them to invalid values.In the second place,...
General Programming
»
Uncategorised Quick Answers
»
General
C++/MFC
my program won't open the contents of a file
by
Ian A Davidson
Answer
5 May 2013
license:
CPOL
There is a surprisingly large number of issues with this short piece of code (without even mentioning having very strange naming standards).1) I'm not sure it should even compile. A decent compiler won't let you do "first = last = malloc (sizeof (*first));" because you're trying to...
General Programming
»
Uncategorised Quick Answers
»
General
C
file
Errors
help me please on images c#
by
Ian A Davidson
Answer
5 May 2013
license:
CPOL
Clone[^]?
General Programming
»
Uncategorised Quick Answers
»
General
C#
Math Round problem with ToEven or Away From Zero
by
Ian A Davidson
Answer
4 May 2013
license:
CPOL
See the "Notes to Callers" on MSDN's page about this method: Math.Round(Double, Int32, MidpointRounding)[^]: "Because of the loss of precision that can result from representing decimal values as floating-point numbers or performing arithmetic operations on floating-point values, in some cases...
General Programming
»
Uncategorised Quick Answers
»
General
C#
math
Reading a Unicode file saving only the characters.
by
Ian A Davidson
Answer
4 May 2013
license:
CPOL
Check the encoding of your file. First is it really UTF-16? UTF-8 is more common.If it is UTF-16, then you should be reading wide-characters from the file, as Richard has said, and comparing it with 16-bit value of '\n' (_T('\n') or 0x000a), and add the wide-characters to your string.If,...
General Programming
»
Uncategorised Quick Answers
»
General
C++
How to use fscanf to read a line to parse into variables?
by
Ian A Davidson
Answer
3 May 2013
license:
CPOL
You can't. You will need to create a "MyPath" object and allocate some memory for "element" (MyPath really should be a class handling its own memory), and read the line into that buffer. Then you would have to create the next "MyPath", assign its address to "next", and then repeat.fscanf is...
General Programming
»
Uncategorised Quick Answers
»
General
C
file
Top Level Static - What is It
by
Ian A Davidson
Answer
3 May 2013
license:
CPOL
I've tried the method you supplied in the comments of SA's solution, and apart from the incorrect variable (I assume "name" is a typo and should be "classname", or vice versa) it compiles fine as an extension method.It sounds like you're just trying to put it in the wrong place.I would...
General Programming
»
Uncategorised Quick Answers
»
General
C#
alphanumeric increment in C
by
Ian A Davidson
Answer
3 May 2013
license:
CPOL
Yes, go with "the alpha-numeric option" - i.e. how about hexadecimal!?Use %x (or %X) in exactly the same way you would use %d (i.e. you can zero pad, etc) for outputting the value - you probably want to use "%02X"This will mean that you can go up to 0xFF numbers (255).Regards,Ian.
General Programming
»
Uncategorised Quick Answers
»
General
C++
C
read the extension of file using binary mode
by
Ian A Davidson
Answer
2 May 2013
license:
CPOL
It sounds as if you mean that you want to be able to find out what the content of a file is, regardless of filename and extension. In order to do so you would need to research various file format specifications.Wrt JPEGs, all JPEGs always begin with hexadecimal FF D8 (ASCII ÿØ) - the rest...
General Programming
»
Uncategorised Quick Answers
»
General
C++
VisualStudio2012
MFC/C++
How to resolve error C2059
by
Ian A Davidson
Answer
2 May 2013
license:
CPOL
http://msdn.microsoft.com/en-us/library/t8xe60cf(v=vs.80).aspx[^]
General Programming
»
Uncategorised Quick Answers
»
General
COM
VC++
interfaces
.Obj file required in the VC++?
by
Ian A Davidson
Answer
2 May 2013
license:
CPOL
No you don't need it for executing the application. It is an intermediary object file, used by the linker to make the executable. It is common practice to specify a directory for the intermediary files that is different from the output directory, in order to make clean-up and deployment...
General Programming
»
Uncategorised Quick Answers
»
General
MFC
VC++
Application that can start from Windows AND Command Line using C#
by
Ian A Davidson
Answer
1 May 2013
license:
CPOL
The best way in my experience would be to create two applications: a Console application and a Windows Forms application.Then it's up to you how you get the core functionality into both - either link the relevant files into both projects, or create a dll and link both projects to...
General Programming
»
Uncategorised Quick Answers
»
General
C#
arrays with constructors
by
Ian A Davidson
Answer
30 Apr 2013
license:
CPOL
As a sort of exercise for myself and hoping that this will help you learn, I've had a go at "fixing" your code, including a few comments regarding coding standards and the like.However, I would stress that I would not expect to see code like this in any professional project, which I think at...
General Programming
»
Uncategorised Quick Answers
»
General
C++
Get index of a value in a list of doubles
by
Ian A Davidson
Answer
28 Apr 2013
license:
CPOL
If you are using a List how about IndexOf[^] and Max[^].(Max is an extension method, available from .Net 3.5 onwards. IndexOf is available from .Net 2.0).Regards,Ian.
General Programming
»
Uncategorised Quick Answers
»
General
C#
i need source code of php language
by
Ian A Davidson
Answer
27 Apr 2013
license:
CPOL
Apache's PHP module: mod_php[^]or PHP for Windows[^]Regards,Ian.Technically, PHP is a scripting language for websites (although it can be used for programming GUI apps), so references to "PHP source code" really mean the source code of a PHP interpreter or compiler.
General Programming
»
Uncategorised Quick Answers
»
General
PHP
how to make space in result with c++
by
Ian A Davidson
Answer
27 Apr 2013
license:
CPOL
Convert to a string ( hint: look at sprintf ) then iterate through the characters outputting each one followed by a space.Regards,Ian.
General Programming
»
Uncategorised Quick Answers
»
General
C++
create a .Dll with the functions and headers in a specific C-Console application
by
Ian A Davidson
Answer
27 Apr 2013
license:
CPOL
My experience is with C++, but I would guess this is the same for C (except that of course you won't have classes; only functions).Create a dll project. Define a variable on the compiler line (usually using the /d switch).E.g. for your example, you might choose something like...
General Programming
»
Uncategorised Quick Answers
»
General
C
DLL
API
calculate the memory space allocated by a structure in C
by
Ian A Davidson
Answer
27 Apr 2013
license:
CPOL
For debug only, look at the _CrtMem... functions: _CrtMemCheckpoint, _CrtMemDifference, and the related functions. They are the ones I used to use for C++, but sadly I don't think I have any remaining examples.Regards,Ian._CrtMemCheckpoint[^]_CrtMemDifference[^]
General Programming
»
Uncategorised Quick Answers
»
General
C
static pointer data member
by
Ian A Davidson
Answer
26 Apr 2013
license:
CPOL
Where you have implemented the static pointers, you have placed the asterisk in the wrong place; it needs to be before the class name part of the declaration. Actually, this is one example where placing the asterisk next to the type name, instead of putting it with the variable, would help not...
General Programming
»
Uncategorised Quick Answers
»
General
C++
Ubuntu
Help Me Find The Problem
by
Ian A Davidson
Answer
25 Apr 2013
license:
CPOL
Right, well I've taken your code and tidied it up, without changing the functionality.However, the most worrying thing about this code is that even after doing all this, I still cannot see what the code does.If I enter "hello" and "goodbye" it outputs "e", "o" and "o".What does it all...
General Programming
»
Uncategorised Quick Answers
»
General
VC++
C++ declaring array while the program is running
by
Ian A Davidson
Answer
25 Apr 2013
license:
CPOL
An alternative to using new and delete is to use the STL (standard template library) vector class - then you don't need to worry about deallocating since the vector class handles it.E.g.#include void foo(){ std::cin >> len; std::vector a(len); // use the...
General Programming
»
Uncategorised Quick Answers
»
General
C++
problem in using new operator
by
Ian A Davidson
Answer
24 Apr 2013
license:
CPOL
Without changing too much, try this instead:#include #include void main(){ clrscr(); int *p1,n,i; cout>n; p1=new int[n]; for(i=0;i>p1[i]; for(i=n;i>0;i--) ...
General Programming
»
Uncategorised Quick Answers
»
General
C++
File system watcher sometimes does not pick up files properly even if the window service is running properly
by
Ian A Davidson
Answer
23 Apr 2013
license:
CPOL
I am sorry that I only saw this question today. I have a several years' experience with FileSystemWatcher (and with the Win32 API functions when using C++ before C#).These are the main areas to look out for:1) As you said, make sure the code that handles notifications is as quick as...
General Programming
»
Uncategorised Quick Answers
»
General
C#
Windows
system
Events
file
file-system
Services
Fileinfo error " too long path"
by
Ian A Davidson
Answer
20 Apr 2013
license:
CPOL
The method of getting information about files whose filename is too long is to P/Invoke to the Windows API. I believe that's what the libraries which Zoltán has linked to will be doing under the hood (in fact the first one even links to some pages about it), so I won't add to that information...
General Programming
»
Uncategorised Quick Answers
»
General
C#
MSXML2::IXMLDOMDocumentPtr Save throwing exception.
by
Ian A Davidson
Answer
13 Apr 2013
license:
CPOL
I doubt we'd be able to help you with this online, as you'd probably need to debug it. At the very least some more information would be needed.However, having said that:1) Are you making sure that you close (dispose) any object (e.g. StreamWriter) that you use to access the file?2)...
General Programming
»
Uncategorised Quick Answers
»
General
C++
VC10.0
how count object in project of my class in c sharp
by
Ian A Davidson
Answer
13 Apr 2013
license:
CPOL
See the example at the bottom of this page: Interlocked.Increment Method[^]Of course, your implementation will use only the Interlocked methods, won't it ;)Regards,Ian.
General Programming
»
Uncategorised Quick Answers
»
General
C#
Use of C++ Constructor
by
Ian A Davidson
Answer
13 Apr 2013
license:
CPOL
What exactly are you asking for?A default constructor is simply a constructor that has no parameters and a copy constructor is one whose only parameter is an instance of the same class (usually a const reference).E.g.class MyClass{ public: // Default constructor ...
General Programming
»
Uncategorised Quick Answers
»
General
C++
Re: An exception thrown inside Singletin's .ctor will be thrown ...
by
Ian A Davidson
Forum Message
11 Apr 2013
My answer was in response to your assertion:Quote:An exception thrown inside Singletin's .ctor will be thrown on type initialization (instead of first acc
General Discussions
»
Alternative Tip "Simple Singleton Pattern In C#"
Re: Singleton
by
Ian A Davidson
Forum Message
10 Apr 2013
Not true! All the examples given eliminate race conditions for the construction of the single instance object only. Once created, different threads will be accessing the same object. Therefore all
General Discussions
»
Article "Singleton Pattern – Positive And Negative Aspects"
Re: Singleton inheritance
by
Ian A Davidson
Forum Message
10 Apr 2013
An interesting idea, but it seems rather convoluted for a few very basic methods. If concerned about inconsistency, these methods could easily be automatically "created" for you (assuming you are us
General Discussions
»
Article "Singleton Pattern – Positive And Negative Aspects"
Static classes
by
Ian A Davidson
Forum Message
10 Apr 2013
Quote:You cannot specify any creation logic with static methods.I'm not sure what you mean by "creation logic with static methods, but if you
General Discussions
»
Article "Singleton Pattern – Positive And Negative Aspects"
Re: An exception thrown inside Singletin's .ctor will be thrown ...
by
Ian A Davidson
Forum Message
10 Apr 2013
It is wrong that an exception might be thrown "even if never used". Because the field is static, it will be created when the class is first accessed. So an exception thrown by the constructor would
General Discussions
»
Alternative Tip "Simple Singleton Pattern In C#"
Re: Reason for my vote of 2This alternative is not 'lazyloading...
by
Ian A Davidson
Forum Message
10 Apr 2013
As far as "Lazy loading" goes, in terms of when the Singleton instance is created there is unlikely to be any noticeable difference between: Option 1:sealed class Singl
General Discussions
»
Alternative Tip "Simple Singleton Pattern In C#"
Re: Reason for my vote of 5the simplest and because of it the b...
by
Ian A Davidson
Forum Message
10 Apr 2013
It is one option. It is not necessarily the "best". There may be times to use this option, but there may be times to use the option of creating the single instance object from within the "Instance"
General Discussions
»
Alternative Tip "Simple Singleton Pattern In C#"
Page 1 of 2
1
2
First
·
Prev
·
Next
·
Last
Advertise
|
Privacy
|
Mobile
Web03 | 2.6.130513.1 | Last Updated 14 May 2013
Copyright ©
CodeProject
, 1999-2013
All Rights Reserved.
Terms of Use
Layout:
fixed
|
fluid