#include <stdlib.h>
#include <stdio.h>
int main() {
char str[] = "Ola. Tudo bem?\n Sim e contigo?\n Comigo esta tudo bem! Que tens feito?\n Trabalho no projeto!\n";
char **matriz
= malloc(sizeof(char *) * 255); int linha = 0;
for (int caractere = 0, coluna = 0; str[caractere] != '\0'; caractere++, coluna++) {
if (str[caractere] == '\n' || str[caractere] == '\0') {
matriz[linha][coluna] = '\0';
matriz
[linha
] = realloc(matriz
[linha
], coluna
+ 1); matriz
[++linha
] = malloc(255); coluna = -1;
} else {
matriz[linha][coluna] = str[caractere];
}
}
matriz
= realloc(matriz
, sizeof(char *) * linha
); for (int i = 0; i < linha; i++) {
}
}
//https://pt.stackoverflow.com/q/254177/101
I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RkaW8uaD4KCmludCBtYWluKCkgewoJY2hhciBzdHJbXSA9ICJPbGEuIFR1ZG8gYmVtP1xuIFNpbSBlIGNvbnRpZ28/XG4gQ29taWdvIGVzdGEgdHVkbyBiZW0hIFF1ZSB0ZW5zIGZlaXRvP1xuIFRyYWJhbGhvIG5vIHByb2pldG8hXG4iOwoJY2hhciAqKm1hdHJpeiA9IG1hbGxvYyhzaXplb2YoY2hhciAqKSAqIDI1NSk7CglpbnQgbGluaGEgPSAwOwoJbWF0cml6W2xpbmhhXSA9IG1hbGxvYygyNTUpOwogICAgZm9yIChpbnQgY2FyYWN0ZXJlID0gMCwgY29sdW5hID0gMDsgc3RyW2NhcmFjdGVyZV0gIT0gJ1wwJzsgY2FyYWN0ZXJlKyssIGNvbHVuYSsrKSB7CiAgICAgICAgaWYgKHN0cltjYXJhY3RlcmVdID09ICdcbicgfHwgc3RyW2NhcmFjdGVyZV0gPT0gJ1wwJykgewogICAgICAgICAgICBtYXRyaXpbbGluaGFdW2NvbHVuYV0gPSAnXDAnOwogICAgICAgICAgICBtYXRyaXpbbGluaGFdID0gcmVhbGxvYyhtYXRyaXpbbGluaGFdLCBjb2x1bmEgKyAxKTsKICAgICAgICA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