begyu

Hozzászólások

10 bejegyzés megtekintése - 101-110 / 118
  • Szerző
    Bejegyzés
  • Hozzászólás: ProbleM: int argc,char *argv[] #1999033
    begyu
    Felhasználó

      Hi

      A gcc infoban talalsz ilyet:

      Code:
          #include
         
          void va_start(va_list ap, LAST_REQUIRED_ARG);
          TYPE va_arg(va_list ap, TYPE);
          void va_end(va_list ap);

      Description
      ———–

      Used to write functions taking a variable number of arguments.  Note
      that these are actually macros, and not functions.  You must prototype
      the function with `…’ in its argument list.  Then, you do the
      following:

        *  Create a variable of type `va_list’.

        *  Initialize it by calling `va_start’ with it and the name of the
          last required (i.e. non-variable) argument.

        *  Retrieve the arguments by calling `va_arg’ with the `va_list’
          variable and the type of the argument.  As another alternative,
          you can pass the `va_list’ to another function, which may then use
          `va_arg’ to get at the arguments.  `vprintf’ is an example of this.

        *  Call `va_end’ to destroy the `va_list’.

      Be aware that your function must have some way to determine the number
      and types of the arguments.  Usually this comes from one of the required
      arguments.  Some popular ways are to pass a count, or to pass some
      special value (like `NULL’) at the end.

      Also, the variable arguments will be promoted according to standard C
      promotion rules.  Arguments of type `char’ and `short’ will be promoted
      to `int’, and you should retrieve them as such.  Those of type `float’
      will be promoted to `double’.

      Return Value
      ————

      `va_arg’ returns the argument it fetched, the other macros return
      nothing.

      Portability
      ———–

      ANSI/ISO C   C89; C99
      POSIX        1003.2-1992; 1003.1-2001

      Example
      ——-

          int find_the_sum(int count, …)
          {
            va_list ap;
            int i;
            int total = 0;
         
            va_start(ap, count);
            for (i = 0; i < count; i++)           total += va_arg(ap, int);       va_end(ap);       return total;     }         int other_function(void)     {       return find_the_sum(6, 1, 2, 3, 4, 5, 6);     }

      Ezzel ugy lehet parameterezni egy fuggvenyt, mint a main()-t.

      begyu
      Felhasználó

        Idezojelet stringen belul igy irj:

        Code:
        Hozzászólás: UHU-menü szerkesztése #1995067
        begyu
        Felhasználó

          Szasztok!

          Lehet h. butasagot mondok, mivel nem hasznalom a KDE-t,
          de nem lehet a /usr/lib/applications/progineve.desktop file-ok
          szerkesztesevel megoldani?

          Hozzászólás: pascal – gyökvonás #1991657
          begyu
          Felhasználó

            Valamikor *akodtam vele, probald meg ezt is:

            Code:
            function power(num,exponent:real; var error:boolean):real;
            function psub:real;
            var i:integer;
                x:real;
            begin
              x:=num;
              if (exponent=int(exponent)) and (trunc(exponent) in [1..100])
              then begin
                for i:=1 to trunc(exponent)-1 do x:=x*num;
                psub:=x end
              else psub:=exp(exponent*ln(num))
            end;
            begin
             power:=0;
             error:=false;
             if exponent=0 then if num=0 then error:=true else power:=1
             else if num=0 then if exponent>0 then power:=0
                                else error:=true
                  else if num>0 then if abs(exponent*ln(num))>88 then error:=true
                                     else power:=psub
                       else if int(exponent)=exponent then
                                 if exponent<0 then
                                    power:=1/power(num,abs(exponent),error)
                                 else if odd(trunc(exponent)) then
                                         power:=-power(abs(num),exponent,error)
                                      else power:=power(abs(num),exponent,error)
                            else error:=true
            end; {power}

            function root(exponent,num:real; var error:boolean):real;
            begin
             root:=0;
             if num<0 then error:=true
             else if exponent=0 then error:=true
                  else root:=power(num,(1/exponent),error);
            end;

            ez kikeruli a hibalehetosegeket is.

            Hozzászólás: sed és tr parancs helyes használata #1991579
            begyu
            Felhasználó

              hi,

              Szinte biztos voltam abban hogy találok vmit ha rákeresek ezekre, de aztán koppantam, mert nem adott találatot a keresõ  :angry:

              A kérdésem a köv. lenne. Van pl egy fileom (pl.: adat.dat) amiben minden sorban van 2-3db (tökmind1mennyi) ; karakter. Ezt le szeretném cserélni pl tabulátor jelre, vagy szóközre. Mi ennek a szintaktikailag tökéletes kivitelezése sed ill. tr parancs esetében?

              Hozzászólás: programozzunk, de most már komolyan… #1985753
              begyu
              Felhasználó

                Sziasztok!

                Nem akarok senkit bosszantani egy DOS-os dologgal, de akit erdekel, nezze meg
                A’rpi szulemenyet. Ugy hijjak, h. BAssPasC. Engem annak idejen total lenyugozott.
                Aki szereti a bitfaragast, el fog elvezni tole!

                Itt egy pelda:

                Code:
                .386

                uses stdvga
                include stdvga.h

                var ora,perc,sec:DB

                {var
                 szog    DW ?
                 szogek  DW 60,30,0,330,300,270,240,210,180,150,120,90,60
                 szamstr DW 0,0
                 jelstr  DB ”,0
                }

                initgraph

                circle(320,240,60,10)
                FOR BX=0 to 12 do push(all)//!szamok

                repeat
                 !dido
                 ax:=2//!delay
                 !cido
                until keypressed

                closegraph
                exit

                szamok:
                 <>BX,1
                 AL:=BL//++AL//AH:=0
                 if AL>9 do AH+=31h//AL-=10
                 AL+=30h
                 if AH!=0 do AH<>AL
                 szamstr:=AX
                 getvect(315,238,70,szog)
                 outstr(ax,bx,ofs szamstr)
                 getvect(317,237,55,szog)
                 outstr(ax,bx,ofs jelstr)
                ret

                dora:
                 push CX
                   if AX>12 do AX-=12
                   –AL
                   BX:=AX
                   <9 then
                   AH:=0
                   AL:=CL//>>AL,1
                   if DX=0 do DX:=350//else DX-=AX
                 endif
                 vect(320,240,30,dx)
                 circle(320,240,5)
                ret

                dperc:
                 BL:=5
                 div BL
                 BL:=AL//BH:=0
                 <mutato

                dido::
                 setgcolor(10)
                 DOS 2Ch
                 ora:=CH
                 perc:=CL
                 sec:=DH
                 DL:=0
                mutato:
                 push DX
                   push(all) ax:=ch//!dora
                   ax:=cl//!dperc
                 pop DX
                 if DL==0 do setgcolor(11)
                 ax:=dh//!dperc
                ret

                delay::
                 CX:=AX
                 DX:=0
                 AH:=86h
                 INT 15h
                ret

                Ez analog orat csinal, a prg merete 900 bajt!

                Egy hasonlo forras MENUETOS ala:

                Code:
                #include

                #define B_SZ 10

                static char * Title=”BinClock”;

                void draw_small_box(int x,int y,int is_on)
                {
                __menuet__bar(x,y,B_SZ,B_SZ,is_on ? 0xFF0000 : 0x103000);
                }

                void draw_box_group(int x,int y,int num)
                {
                int i,j;
                char buf[2];
                buf[0]=(num&(1+2+4+8))+’0′;
                buf[1]=’’;
                for(i=0;i<4;i++)
                {
                 j=(B_SZ+2)*i;
                 draw_small_box(x,y+((B_SZ+2)*i),num & (1<<(3-i)) ? 1 : 0); } __menuet__bar(x,y+((B_SZ+2)*4),B_SZ,B_SZ,0x800000); __menuet__write_text(x+2,y+((B_SZ+2)*4)+3,0xFFFFFF,buf,1); } void draw_bcd_num(int x,int y,int num) { int v1,v2; v1=(num>>4)&(1+2+4+8);
                v2=num & (1+2+4+8);
                draw_box_group(x,y,v1);
                draw_box_group(x+B_SZ+2,y,v2);
                }

                void draw_hms(int x,int y)
                {
                __u32 t;
                int h,m,s;
                t=__menuet__getsystemclock();
                s=(t & 0x00FF0000)>>16;
                m=(t & 0x0000FF00)>>8;
                h=(t & 0x000000FF);
                draw_bcd_num(x,y,h);
                x+=((B_SZ+2)<<1)+2; draw_bcd_num(x,y,m); x+=((B_SZ+2)<<1)+2; draw_bcd_num(x,y,s); } void draw_h(void) { draw_hms(22,28); } void paint(void) { __menuet__window_redraw(1); __menuet__define_window(100,100,40+((B_SZ+2)*6)+4,30+((B_SZ+2)*4)+16,0x03000080,0x800000FF,0x000080); __menuet__write_text(3,3,0xFFFFFF,Title,strlen(Title)); __menuet__bar(20,26,((B_SZ+2)*6)+4+2,4+((B_SZ+1)*4)+2,0); draw_h(); __menuet__window_redraw(2); } void app_main(void) { int i; paint(); for(;;) {  __menuet__delay100(20);  i=__menuet__check_for_event();  draw_h();  switch(i)  {   case 1:    paint();    continue;   case 2:    __menuet__getkey();    continue;   case 3:    if(__menuet__get_button_id()==1) __menuet__sys_exit();    continue;  } } }  

                Hozzászólás: text feldolgozas c-ben #1977556
                begyu
                Felhasználó

                  Hali!

                  A ciklust tedd blokkba!

                  Hozzászólás: c header fileok mit tartalmaznak? #1976917
                  begyu
                  Felhasználó

                    Akkor megkérdezem, h Te honnan ismerted meg azt a 90%-os tudást?

                    Hali!

                    Probald ki ezt parancssorban:

                    Code:
                    Info libc functional

                    Asszem ez kell neked.

                    Ha a VC++ az NCURSES-t le tudja forditani, akkor hasznalni is lehet. Gondolom en.

                    Hozzászólás: xedit/kedit #1937958
                    begyu
                    Felhasználó

                      Itt egy levlista: http://listserv.uiuc.edu/archives/thelist.html
                      Ha erdekel az altalam buheralt forras, akkor: http://begyu.uw.hu
                      Most lejart a munkaidom, huzok haza!

                      Hozzászólás: xedit/kedit #1937956
                      begyu
                      Felhasználó
                      10 bejegyzés megtekintése - 101-110 / 118