When I run the code (codes in attached image) nothing appears on the output screen when I try argv[]
as arguments of strncmp()
function. I searched on the web but I did not see any application like this for strncmp!
Everything I found was nearly like this:
int strncmp(
const char *string1,
const char *string2,
size_t count
);
I tried the codes in the image I attached in MSVC like this:
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include<string.h>
void main(int argc, char *argv[]) {
system("cls");
if (!strncmp(argv[1], argv[2], 8))
printf("Both strings are the same!");
else
printf("Not same!");
}
But nothing was on the output screen and no error and no warnings detected by MSVC. argv[1]
and argv[2]
each one is .txt files which I create before and their contents are exactly the same.
Then, I tried this code with two string arrays instead of previous .txt files, and it worked as I expected and fine. (According the strings the output was "Both strings are the same!" or "Not same!" )
How can I rewrite the codes in the image I attached, so that it works in MSVC as well?! How I pass my command line arguments It works on code::blocks