//prints out address information with no user input
void automatic(){
	char line[LINE_LENGTH];
	char command[20];
	status=1;

	strcpy(command, "getadr.sh address.dat");
	system(command);

	FILE *file=fopen("address.dat", "r");
	
	if (fgets(line, LINE_LENGTH, file) == NULL){
		printf("There was an error reading the file\n");
		return;
	}
	sscanf(line, "%s", hostAddress);

	if (fgets(line, LINE_LENGTH, file) == NULL){
		printf("There was an error reading the file\n");
		return;
	}
	sscanf(line, "%s", mask);
	fclose(file);
	
	calcPrefix();
	calcNetAdd();
	calcHostPortion();
	printf("\n");
}
Esempio n. 2
0
 bool kmp(int x, string &s) {
     string p = sub[x];
     vector<int> pi;
     calcPrefix(p, pi);
     int t = 0, l = p.size();
     while (k < n) {
         while ((t > 0) && !isMatchChar(p[t], s[k]))
             t = pi[t];
         if (isMatchChar(p[t], s[k])) 
             t++;
         k++;
         if (t == l) 
             return true;
     }
     return false;
 }
Esempio n. 3
0
int main(){
	char prefixBuffer[STR_SIZE*2];
	int prefixIndex = 0;
	double result = 0.0;

	STACK charStack;
	STACK intStack;

	initStack(&charStack, "char");
	initStack(&intStack, "double");

	makePrefix(prefixBuffer, &charStack, &prefixIndex);
	result = calcPrefix(prefixBuffer, &intStack, &prefixIndex);

	printf(" %.2lf \n", result);

	return 0;
}