Thursday 30 January 2014

LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt


Causes:
This error appear because you have installed Visual C++ 2012 after you
have actually installed Visual C++ 2010 in your system;
another cause is because .net Framework 4.5 replace .net Framework 4.0;
.net Framework corrupted files;
 
How To Solve:
Solution 1:
Either disable incremental linking, by going to
Project Properties
   -> Configuration Properties
       -> Linker (General)
          -> Enable Incremental Linking -> "No (/INCREMENTAL:NO)"

 
 
 
Solution 2:
If disabling incremental linking doesn't work for you, and turning off
"Embed Manifest" doesn't work either, then search your path for multiple
versions of CVTRES.exe.
 
By debugging with the /VERBOSE linker option I found the linker was
writing that error message when it tried to invoke cvtres and it failed.
It turned out that you had two versions of this utility in your path.
 
One at C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cvtres.exe and
one at C:\Windows\Microsoft.NET\Framework\v4.0.30319\cvtres.exe.
 
After VS2012 install, the VS2010 version of cvtres.exe will no longer
work.
If that's the first one in your path, and the linker decides it
needs to convert a .res file to COFF object format, the link will fail
with LNK1123.
(Really annoying that the error message has nothing to do with the
actual problem, but that's not unusual for a Microsoft product.)
 
Solution:
Just delete/rename the older version of the utility, or re-arrange your
PATH variable, so that the version that works comes first. I mostly use renamed the old version file.
 
Solution 3:
-> If Visual Studio 2012 RC and Visual Studio 2010 with SP1 are installed on the same computer then you will be re-install VS 2010 with SP1,
-> If you have Visual Studio 2012 RC  and Visual Studio 2010 then you will be install Visual Studio 2010 with SP1.
you can open the project in both of those versions of Visual Studio.
 
Solution 4:
Uninstall .Net Framework 4.5 from your system and re-install .Net Framework 4.0.

 
   

Wednesday 15 January 2014

How to open a URL in the default web browser?


This is easily done by calling ShellExecute() HTTP and FTP URLs should be processed by both Netscape and IE: the "default" browser will handle them. Other protocols such as mailto and news may also handled by the browser. IE4 adds handlers for things like "Callto:" for Net Meeting contacts.

#include "windows.h"
 #include "shellapi.h"
 //link in the library
#pragma comment(lib,"shell32.lib")
 
int main(int argc, char *const argv[])
{
    ShellExecute(NULL,"open", "http://coderdreambook.blogspot.in/", "", "c:\\", SW_SHOWNORMAL);
    return 0;
}

Saturday 11 January 2014

What is a pdb file?

A program database (PDB) file contains debugging and project state information that allows incremental linking of a Debug configuration of the program. This file is created when you compile a C/C++ program with /ZI or /Zi or a Visual Basic/C#/JScript .NET program with /debug.

When do you call copy constructors?

Copy Constructor:  It is a constructor, which initializes it's object member variable with another object of the same class. If you don't implement a copy constructor in your class, the compiler automatically does it.

Copy constructors are called in these situations: 

i.)when compiler generates a temporary object 
ii.)when a function returns an object of that class by value 
iii.)when the object of that class is passed by value as an argument to a function 
iv.)when you construct an object based on another object of the same class

Get the middle node in a given singly linked list?


struct node
{
   int info;
   struct node *next;
};

struct node* getMiddleNode(struct node **start)
{
  struct node *middle = *start;
  struct node *fast_ptr = *start;

  if(*start != NULL)
  {
       while((fast_ptr->next) !=NULL && (fast_ptr->next->next) != NULL)
       {
          fast_ptr = fast_ptr->next->next;
          middle middle->next;
       }
  }

   return middle ;
}