text stringlengths 0 104 |
|---|
int _tmain(int argc, _TCHAR* argv[]) |
{ |
char name[64]; |
printf("Enter your name: "); |
scanf("%s", name); |
Sanitize(name); |
printf("Welcome, %s!", name); |
return 0; |
} } |
#include <stdio.h> |
#include <stdlib.h> |
int main() { |
char filename[256]; |
printf("Enter filename: "); |
scanf("%s", filename); |
FILE *f = fopen(filename, "r"); |
if (f) { |
char buf[1024]; |
while (fgets(buf, sizeof(buf), f)) { |
printf("%s", buf); |
} |
fclose(f); |
} |
return 0; |
} |
#include <stdio.h> |
#include <string.h> |
#define MAX_USERS 100 |
typedef struct { |
char username[32]; |
char password[32]; |
int role; |
} User; |
User users[MAX_USERS]; |
void add_user(const char *name, const char *pass) { |
static int count = 0; |
strcpy(users[count].username, name); |
strcpy(users[count].password, pass); |
users[count].role = 0; |
count++; |
} |
int main() { |
char name[256]; |
char pass[256]; |
printf("Username: "); |
gets(name); |
printf("Password: "); |
gets(pass); |
add_user(name, pass); |
printf("User %s added.\n", users[0].username); |
return 0; |
} |
#include <stdio.h> |
#include <string.h> |
#include <stdlib.h> |
char *concat_args(int argc, char *argv[]) { |
char result[64]; |
result[0] = '\0'; |
for (int i = 1; i < argc; i++) { |
strcat(result, argv[i]); |
strcat(result, " "); |
} |
char *output = malloc(strlen(result) + 1); |
strcpy(output, result); |
return output; |
} |
int main(int argc, char *argv[]) { |
char *combined = concat_args(argc, argv); |
printf("Combined: %s\n", combined); |
free(combined); |
return 0; |
} |
#include <stdio.h> |
#include <string.h> |
#include <stdarg.h> |
void log_message(const char *fmt, ...) { |
char buf[128]; |
va_list args; |
va_start(args, fmt); |
vsprintf(buf, fmt, args); |
va_end(args); |
printf("[LOG] %s\n", buf); |
} |
int main(int argc, char *argv[]) { |
if (argc > 1) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.