Няшная / Говнокод #25799 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
#include <stdio.h>
#include <stdlib.h>


int main(int argc, char *argv[])

//типа explode в php;
{
int i=0;
//char s=';';
char s=argv[2][0];

i=100;
//char** data;
//data=(char**)malloc(i+1);
char data[1000][1000];
char* str;
str=malloc(i+1);
str=argv[1];
printf("%s\n",str );
int n=0;
int m=0;


while (*str) {
if (*str==s)
{m++;n=0;str++;continue;};
  data[m][n]=*str;
  str++;n++;

};
printf("%s\n",data[0] );

}

Типа explode в php
Кто-нить знает как это заставить работать с
//char** data;
//data=(char**)malloc(i+1);
??

Запостил: killer1804 killer1804, (Updated )

Комментарии (23) RSS

    • #include <stdio.h>
      
      #include <stdlib.h>
      
      
      int main(int argc, char * argv[])
      
      //типа explode в php;
      {
        int i = 0;
        //char s=';';
        char s = argv[2][0];
      
        i = 100;
        //char** data;
        //data=(char**)malloc(i+1);
        char data[1000][1000];
        char * str;
        str = malloc(i + 1);
        str = argv[1];
        printf("%s\n", str);
        int n = 0;
        int m = 0;
      
        while ( * str) {
          if ( * str == s) {
            m++;
            n = 0;
            str++;
            continue;
          };
          data[m][n] = * str;
          str++;
          n++;
      
        };
        printf("%s\n", data[0]);
      
      }
      Ответить
    • Да. Баллы за лабу снимают. У вас так не было?
      Ответить
        • И правильно сделали. Если ты хочешь быть JSером, то нахрена учиться на программиста?
          Ответить
          • Я повелся на пиздеж непонятных няш, которые говорили про какие-то фундаментальные знания
            Ответить
            • Я тоже за "фундаментальные знания".
              Ответить
              • Котлованные знания глубинного народца.
                Ответить
  • Как можно "учить \"Си\"" 9 лет, и так и не выучить? Неужели это так сложно?
    Ответить
  • Специальную олимпиаду обьявляю открытой:
    https://wandbox.org/permlink/IYj93ntrjwgxpxlt
    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>
    
    char* str(char* data, unsigned strIndex, unsigned strSize) {
      return data + strIndex * strSize;
    }
    
    int main(int argc, char* argv[]) {
      if (argc < 2)
        return 1;
      
      const unsigned strsize = 1000;
      const unsigned strcount = 1000;
      const char s = ';';
      
      char* data = calloc(strsize, strcount);  
      char* haystack = argv[1];
      
      unsigned nstrings = 0;
      while (haystack) {
        char *end = strchr(haystack, s);   
        char *dest = str(data, nstrings, strsize);
        
        if (end) {
          unsigned length = end - haystack; 
          memcpy(dest, haystack, length > strsize ? strsize : length);
          end += 1;
        } else {
          strcpy(dest, haystack);
        }
    
        haystack = end;
        if (++nstrings == strcount)
          break;
      }
       
      for (unsigned i = 0; i < nstrings; ++i)
        printf("[%d] %s\n", i, str(data, i, strsize));
      
      free(data);
    }


    https://wandbox.org/permlink/IYj93ntrjwgxpxlt
    Ответить

Добавить комментарий

Помни, guest, за тобой могут следить!

    А не использовать ли нам bbcode?


    8