tanszek:oktatas:techcomm:lzw_coding
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tanszek:oktatas:techcomm:lzw_coding [2024/11/18 20:24] – [Key Steps in LZW Compression] knehez | tanszek:oktatas:techcomm:lzw_coding [2024/11/19 07:54] (current) – knehez | ||
|---|---|---|---|
| Line 124: | Line 124: | ||
| + | C implementation of LZW encoding: | ||
| + | <sxh c> | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | #define MAX_sxhS 100 | ||
| + | |||
| + | char sxhTable[MAX_sxhS][10] = {" | ||
| + | |||
| + | int tableElements = 5; | ||
| + | |||
| + | int isInsxhTable(char *s) | ||
| + | { | ||
| + | for(int i = 0; i < tableElements; | ||
| + | { | ||
| + | if(strcmp(sxhTable[i], | ||
| + | { | ||
| + | return i; | ||
| + | } | ||
| + | } | ||
| + | return -1; | ||
| + | } | ||
| + | |||
| + | int main() | ||
| + | { | ||
| + | char text[] = " | ||
| + | char *p = text; | ||
| + | int bufferEnd = 1; | ||
| + | |||
| + | int lastFoundIndex = -1; | ||
| + | while(*p != ' | ||
| + | { | ||
| + | char subStr[10]; | ||
| + | strncpy(subStr, | ||
| + | subStr[bufferEnd] = ' | ||
| + | int foundIndex = isInsxhTable(subStr); | ||
| + | if(foundIndex != -1) | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | p += strlen(subStr) - 1; | ||
| + | bufferEnd = 1; | ||
| + | strcpy(sxhTable[tableElements++], | ||
| + | printf(" | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
tanszek/oktatas/techcomm/lzw_coding.1731961459.txt.gz · Last modified: 2024/11/18 20:24 by knehez
