#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int length;
int* ascii;
} ASCIIString;
ASCIIString convertToASCII(const char* input) {
int length = strlen(input);
int nullCount = 0;
for (int i = 0; i < length; i++) {
if (input[i] == '\0') {
nullCount++;
}
}
int* ascii = malloc((length + nullCount + 1) * sizeof(int));
int currentIndex = 0;
for (int i = 0; i < length; i++) {
ascii[currentIndex++] = (int)input[i];
if (input[i] == '\0') {
ascii[currentIndex++] = 0;
}
}
ASCIIString result;
result.length = currentIndex;
result.ascii = ascii;
return result;
}
void printConvertedASCII(const char* inputString) {
ASCIIString result = convertToASCII(inputString);
printf("Converted ASCII string: ");
for (int i = 0; i < result.length; i++) {
printf("%c", result.ascii[i]);
}
printf("\n");
free(result.ascii);
}
int main() {
const char* inputString = "http://d.ebullpower.com";
printConvertedASCII(inputString);
return 0;
}