Click here to Skip to main content
Page 1 of 2
Page Size: 10 · 25 · 50


Author filtered by: Ian A Davidson [x]
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.
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...
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...
C#
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...
C#
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.
C
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...
C++
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...
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.
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...
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.
MFC
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...
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." ...
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...
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...
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...
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...
C#
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,...
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...
help me please on images c# by Ian A Davidson
Answer 5 May 2013   license: CPOL
Clone[^]?
C#
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...
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,...
C++
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...
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...
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.
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...
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[^]
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...
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...
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...
C++
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.
C#
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.
PHP
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.
C++
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...
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[^]
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...
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...
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...
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--) ...
C++
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...
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...
C#
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)...
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.
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 ...
C++
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
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
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
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
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
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
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"

Page 1 of 2
1 2


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