Wednesday, November 20, 2013

Install Microsoft SDK on Win7

Tonight is a both difficult and "teaching" night. I am very excited to record what I learned, thanks to those obstacles and questions.

Goal: Install Microsoft SDK 7.1 to work with MATLAB.

I have got three types of SDK but didn't know which to install. They are GRMSDK_EN_DVD.iso, GRMSDKX_EN_DVD.iso and GRMSDKIAI_EN_DVD.iso. So here came my first question - what's the difference? Googling my question, it turned out that GRMSDK_EN_DVD is for x86, adding an X to GRMSDK for x64, and adding IAI for Itanium. OK, I chose the "X" one to cooperate with my MATLAB which is x64 version.

When installing the SDK, "return code 5100" baffled me a lot. Answer is in stackoverflow. I uninstalled Visual C++ 2010 Redistribute, but there were Visual C++ 2010 Designtime, Visual C++ 2010 Runtime and Visual C++ 2010 Redistribute. Again what's the difference? Stackoverflow is amazing, right? It tells me the difference is like difference between debug and release. Fine, continue installation.

Great! Successfully installed!




Monday, November 11, 2013

Alternately Store Elements of Two Char Arrays

Recently I was asked a question, i.e. how to output two char arrays alternately. It is easy to work out, so the main point here may be to practice my writing skills and to increase the number of my blogs. By the way, record my solution. I chose to store them first and then you could do anything as you like. Maybe output it. Maybe pass it. Whatever.

#include <stdio.h>
#include <string.h>

int main()
{
    char a[512]={0}, b[512]={0}, buf[1024]={0};
    int i=0, length_a=0, length_b=0, minlength=0;
 
    scanf("%s", a);
    scanf("%s", b);

    length_a = strlen(a);
    length_b = strlen(b);
    minlength = length_a > length_b ? length_b : length_a;
    for(i=0; i<minlength; ++i)
    {
        buf[i*2] = a[i];
        buf[i*2+1] = b[i];
    }

    while (i < length_a)
    {
        buf[i+length_b] = a[i++];
    }

    while (i < length_b)
    {
        buf[i+length_a] = b[i++];
    }

    printf("%s", buf);

    return 0;
}