السلام عليكم ورحمة الله وبركاته
أنا مبتدئ في السي و بحاول انزل أكواد جاهزة من النت واقراها علشان تساعدني أفهم في السي أكتر .. لكن ال headers file مش فاهم هي لازمتها ايه و تتفهم إزاي
مثلا البرنامج ده مكون من 3 ملفات :
#ifdef __cplusplus
extern "C" {
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE !FALSE
#endif
int IsWildcardMatch (char *wildcardString, char *stringToCheck, int caseSensitive);
#ifdef __cplusplus
}
#endif#include <stdlib.h>
#include <string.h>
#include "wildcard.h"
int IsWildcardMatch (char *wildcardString, char *stringToCheck, int caseSensitive)
{
char wcChar;
char strChar;
int starMatchesZero = TRUE;
while ((strChar = *stringToCheck) && (wcChar = *wildcardString))
{
*stringToCheck++;
*wildcardString++;
if (!caseSensitive)
{
wcChar = toupper(wcChar);
strChar = toupper(strChar);
}
switch (wcChar)
{
case '*' :
if (starMatchesZero)
*stringToCheck--;
while (*stringToCheck)
{
if (IsWildcardMatch(wildcardString, stringToCheck++, caseSensitive))
return TRUE;
}
break;
case '?' :
break;
default :
if (wcChar != strChar)
return FALSE;
break;
}
}
while ((*wildcardString) && (starMatchesZero))
{
if (*wildcardString == '*')
wildcardString++;
else
break;
}
if ((*stringToCheck) || (*wildcardString))
return FALSE;
else
return TRUE;
}#include <stdio.h>
#include <string.h>
#include "wildcard.h"
int main( int argc, char *argv[] )
{
char string[256]; // you can use either an initialized char array...
char *pattern; // ...or a pointer for the IsWildcardMatch function
if (argc < 3)
{
printf("USAGE: wcTest <pattern> <string>\n\n");
printf("This will return TRUE or FALSE, depending on whether or not\n");
printf("the string matches the wildcard pattern (which can contain\n");
printf("* or ? as wildcard characters).\n\n");
printf("For example: 'wcTest win*.??? windows.bat' will return TRUE.\n\n");
return 1;
}
pattern = argv[1];
strcpy(string, argv[2]);
printf("pattern = %s\nstring = %s\n\n", pattern, string);
if (IsWildcardMatch(pattern, string, FALSE))
printf("match = TRUE\n");
else
printf("match = FALSE\n");
return 0;
}الجزء الأول مش فاهم دوره مع إن البرنامج مش هيشتغل إلا بيه .. لكني فاهم الملفين التانيين . ياريت حد يفهمني الملف الأول ده بيشتغل إزاي