CS 604P Asignment 1
CS 604P Asignment 1
CS604P
Screenshot:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
#include <ctype.h>
int sum = 0;
char name[100];
char modified[100];
int num;
while (fscanf(fp, "%d", &num) == 1)
{
sum += num;
}
fclose(fp);
strcpy(modified, name);
for (int i = 0; modified[i] != '\0'; i++)
{
char ch = tolower(modified[i]);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
modified[i] = '*';
}
}
int main()
{
FILE* check = fopen(INPUT_FILE, "r");
if (!check)
{
FILE* create = fopen(INPUT_FILE, "w");
if (!create)
{
perror("Failed to create input.txt");
return 1;
}
fprintf(create, "10\n20\n30\n40\n50\n");
fclose(create);
}
else
{
fclose(check);
}
return 0;
}