int main(int argc, char *argv[]) { int len; char line[MAXLINE]; char entabLine[MAXLINE]; int i; int tabstop = 8; int start = 0; while (--argc > 0) { switch ((*++argv)[0]) { case '+': tabstop = atoi((*argv)+1); break; case '-': start = atoi((*argv)+1); break; } } while ((len = getline(line, MAXLINE)) > 0) { strcpy(entabLine, line); if (len > start) entab(entabLine+len, line+len, tabstop); else entab(entabLine+start, line+start, tabstop); printf("%s", entabLine); } return 0; }
int main() { int i,c,len,k; char symb1,symb2,symb3; char line[MAX]; for (i=0;i<MAX;++i){ line[i]=0; } len=0; symb1='\t'; symb2=' '; symb3='\n'; while( (len=getl(line,MAX) )>0 ){ printf("string line before detabing=\n%s;\nlen before detabing =%d\n",line,len); for (k=0;k<len;++k) printf("entabed[%d]='%c',entabed[%d+%d-1]='%c',k=%d,\n",k,line[k],k,TAB,line[k-TAB],k); len=entab(line,len); printf("string line after detabing=\n%s;len after detabing=%d\n",line,len); for (k=0;k<len;++k) printf("entabed[%d]='%c',entabed[%d+%d-1]='%c',k=%d,\n",k,line[k],k,TAB,line[k-TAB],k); } for (i=0;i<=len;++i) printf("entabed[%d]=%c",i,line[i]); }
int main() { char input[]= " This is a string"; char output[strlen(input)]; entab(input, output, 8); puts(input); puts(output); }
int main (int argc, char *argv[]) { int tab_pos = TAB; /** we`ll use different pointers for detab() and entab() */ char **tab_poses1 = NULL; char **tab_poses2 = NULL; if (argc == 2) tab_pos = atoi(argv[1]); else if (argc > 2) { tab_poses1 = argv; tab_poses2 = argv; tab_poses1++; tab_poses2++; } //while(tab_poses[0] != NULL) // printf("tab_poses %d\n", atoi((tab_poses++)[0])); printf("\ndoing detab...\n"); detab(tab_pos, tab_poses1); printf("\ndoing entab...\n"); entab(tab_pos, tab_poses2); printf("\n"); return 0; }
int main (int argc, char *argv[]) { char line[LINESIZE]; int ch; strncpy(prog, argv[0], 32); while((ch=getopt(argc, argv, "t:h")) != -1) { switch(ch) { case 't' : tab_size = atoi(optarg); if(tab_size!=4 && tab_size!=8) { printUsage(); exit(1); } break; case 'h' : printUsage(); exit(0); default : exit(1); } } while(fgets(line, LINESIZE, stdin)) printf(entab(line)); return 0; }
int main (int argc, char *argv[]) { int start_pos = 0; int col_per_tab = TAB; if (argc != 3) { printf("\nUsage:\n\t%s -m +n\n\tm -\tstart position (column)\n\tn -\tcolumn per TAB\n", argv[0]); return 1; } else { if (argv[1][0] == '-') start_pos = atoi(argv[1]+1); if (argv[2][0] == '+') col_per_tab = atoi(argv[2]+1); } printf("m = %d\nn = %d\n", start_pos, col_per_tab); printf("\ndoing detab...\n"); detab(start_pos, col_per_tab); printf("\ndoing entab...\n"); entab(start_pos, col_per_tab); printf("\n"); return 0; }
/*replace strings of blanks with tabs*/ int main(int argc, char *argv[]){ int i; char tab[MAXLINE + 1]; settab(argc, argv, tab); entab(tab); return 0; }
main() { char line[1000]; /* current line */ while(entab(line) != 0) { printf("%s", line); } }
int main() { char str[100] = "Hola, veamos si funciona la funcion. Espero que si. Andele, si funciono."; printf("%s", str); entab(str, 100, TABSTOPS); printf("\n"); printf("%s", str); return 0; }
main() { int c; while((c=getchar())!=EOF) while((c=getchar())==' ') entab(); if(c!=' ') putchar(c); }
int main() { int len, max; char line[MAXLINE], longest[MAXLINE]; max = 0; while((len = get_line(line, MAXLINE)) > 0) entab(line, len); return 0; }
main() { int i; while ( (i = getline(s,MAXLINE) ) > 0) { entab(s,TABINC); printf("%s", s); } }
/* replace strings of blanks with tabs */ int main(int argc, char *argv[]) { char tab[MAXLINE+1]; settab(argc, argv, tab); /* initialize tab stops */ entab(tab); /* replace blanks with tabs */ detab(tab); /* replace tab with blanks */ return 0; }
int main(){ int len; char line[MAXLEN]; char newLine[MAXLEN]; while((len = getLine(line, MAXLEN)) != 0){ entab(line, newLine); printf("%s", newLine); } return 0; }
main() { char in_line[LINE_MAX]; char out_line[LINE_MAX]; int len; while ((len = getlines(in_line, LINE_MAX)) > 0) { entab(in_line, out_line); printf("%s", out_line); } }
/* exercise1-21 - Write a program entab that replaces strings of blanks * by the minimum number of tabs and blanks to achieve the same spacing. * Use the same tab stops as for detab. When either a tab or a single * blank would suffice to reach a tab stop, which should be given * preference? * * exercise1-21.c - a program that replaces strings of blanks by the * minimum number of tabs and blanks to achieve the same spacing. Tab * stops are given by parameter TABSTOPS. If only one space is seen * before a tab stop, then a space will be added to the output instead * of a tab. */ int main() { char linein[MAXLINE]; char lineout[MAXLINE]; while (getnline(linein, MAXLINE) > 0) { entab(linein, lineout); printf("%s", lineout); } return 0; }
int main() { int len; char line[MAXLINE]; char entabLine[MAXLINE]; while ((len = getline(line, MAXLINE)) > 0) { entab(entabLine, line, 8); printf("%s", entabLine); } return 0; }
main(){ char string[MAX]="", accum[SIZE]="", entabed[MAX]; int length; while((length = get(string, MAX)) != 0){ entab(string, entabed); concat(accum, accum, entabed); clear(entabed); } printf("\nThe output is:\n%s", accum); return 0; }
int main(){ char line[MAXLINE]; char line_det[MAXLINE]; while ( my_getline(line, MAXLINE) > 0){ printf("%s", line); entab(line_det, line); printf("%s", line_det); } return 0; }
/* &表示\t,*表示空格 */ int main(int argc,char *argv[]) { char *tab; tab=(char *)malloc(100*sizeof(char)); settab(argc,argv,tab); char *sss="1df 567\ta"; char * ss=(char *)malloc(100*sizeof(char)); printf("%s\n",sss); entab(sss,ss,tab); printf("%s\n",ss); return 0; }
/* * Replace blanks with tabs and blanks as to keep the same spacing. */ int main(void) { int len; char line[BUFSIZ]; /* Current input line. */ char tabbed[BUFSIZ]; /* Cooked string with tabs. */ while ((len = getaline(line, BUFSIZ)) != -1) { entab(tabbed, line); printf("%s", tabbed); } return (0); }
int main () { int len; char * line; line = get_input(); if(!line) return 0; char * to_print = entab(line); printf("%s\n", to_print); free(line); free(to_print); return 0; }
void ex1_21(){ char string1[50] = "James Awesome"; char string2[50]; int i; for(i = 0; i < 50; i++) string2[i] = ' '; entab(string2, string1, 4); for(i = 0; i < 50; i++) string2[i] = ' '; detab(string2, string1, 4); printf("%s", string1); printf("\n"); printf("%s", string2); printf("\n"); }
int main(int argc, char *argv[]) { char in[MAXLINE], out[MAXLINE]; while (--argc > 0) switch ((*++argv)[0]) { case '-': m = atoi(++argv[0]); break; case '+': n = atoi(++argv[0]); break; default: printf("Usage: entab -[m] +[n]\n"); argc = 0; break; } if (argc == 0) while (getlinef(in,MAXLINE) > 0) { entab(in, out); printf("%s", out); } return 0; }
int main() { const int LEN = 200; char line[MAXSIZE]; char sout[MAXSIZE]; FILE *fout, *fin; //fout = fopen("output.txt","w"); fout = stdout; fin = stdin; //fin = fopen("in.txt","r"); while (fgetline(line, 200, fin) != NULL) { //fputs(line, fout); int in = 0, out = 0; //fputs(detab(line, sout), fout); fputs(entab(line, sout, &in, &out), fout); fprintf(fout, "%d,%d\n", in, out); } fclose(fout); fclose(fin); return 0; }
main(int argc, char *argv[]) { int count = argc, mul = 1, z = 0, n, array_len; int start_m = 0, tab_n = 8, i, m; char c; start_m = atoi(*++argv); tab_n = atoi(*++argv); m = start_m; printf("m = %d, n = %d\n", start_m, tab_n); /*------creating Tab stops-------*/ for (i = 0; i < 5; i++, mul++) tabs[i] = tab_n * mul; tabs_len = i; /*------print tab stops if required for (i = 0; i < 5; i++) printf("tabs[%d] = %d\n", i, tabs[i]); ---------------------------------*/ printf("Choose a Process : \n"); printf("1 : To process Entab\n"); printf("2 : To process Detab\n"); scanf("%d", &n); switch (n) { case 1: { printf("Enter some characters with spaces\n"); for (z = 0; (c = getchar()) != EOF; ++z) chr_arr[z] = c; array_len = z - 1; printf("Length : %d\n", array_len); entab(array_len,m); } break; case 2: break; } }
int main(int argc, char* argv[]) { const int TAB_OFFSET = 8; entab(TAB_OFFSET); return 0; }
int main(){ entab(); return 0; }
int main() { int tabstop = 4; entab(tabstop); }
/*---------------------------------------------------------------*/ void do_mouse(HWND hwnd, DWORD wParam, DWORD lParam, int msg) { int o,x,y,n,i; static int mox,moy; static char mf2; static char lf2; #ifdef NOCAPT static char wmf; static int mux,muy; #endif switch (msg) { case WM_MOUSEMOVE: //move if ((wParam & MK_RBUTTON)!=0) { #ifdef NOCAPT mox=(short)LOWORD(lParam); moy=(short)HIWORD(lParam); if (wmf==0) { wmf=1,mux=mox,muy=moy; return; } MoveWindow(hwnd,wx0+mox-mux,wy0+moy-muy,wxl,wyl,TRUE); #endif return; } if (clickflag) return; if ((wParam & MK_LBUTTON)==0 || edp==NULL) { mox=(short)LOWORD(lParam); moy=(short)HIWORD(lParam); getmouxy(mox,moy,&x,&y); if (edp==NULL) i=1; else i=inmark(x+clft,y); SetCursor(i?pointC:hCurs); return; } if (lf2==0) return; #ifndef MV_DandD mm3: #endif if (drag) { setdragc(2+(0!=(GetAsyncKeyState(VK_CONTROL)&0x8000))); } n=((wParam & MK_SHIFT)!=0 || 0==moumrk); if (n==0) { mf2=0; goto mm1; } if (mf2) goto mm1; mf2=1; goto mm2; case WM_LBUTTONDBLCLK: lf2=0; if (edp) { o=getkword(fpos, tmpbuff); if (tmpbuff[0]) { ed_cmd(EK_MARK,o, o+strlen(tmpbuff)); return; } } goto drag_cancel; case WM_LBUTTONDOWN: lf2=1; resetmsg(hwnd); if (clickflag && --clickflag) return; //#ifndef MV_DandD SetCapture(hwnd); //#endif n=2; mm1: mox=(short)LOWORD(lParam); moy=(short)HIWORD(lParam); mm2: if (edp==NULL) return; o=getmoupos(mox,moy); if (o) { settimer(hwnd,o,SCROLL_INTERVAL); return; } ed_cmd(EK_SETVAR); getmouxy(mox,moy,&x,&y); if (n==2 && inmark(x+clft,y)) { #ifndef MV_DandD drag=1; goto mm3; #else char *get_block(void); char *get_vblock(void); char *p,*q; int n; p=vmark ? get_vblock() : get_block(); if (p!=NULL) { q = m_alloc(entab (NULL, p, n=strlen(p), tabs)+1); q[entab (q, p, n, tabs)]=0; i=do_drag(q), m_free(q); m_free(p); if (i==1) ed_cmd(KEY_DELETE); } return; #endif } if (drag && linmrk && vmark==0 && fixline(*ma) != fixline(*me)) curx=0; if (drag && n!=2 && dragmove<2) dragmove++; if (n==2) unmark(); if (drag==0) setvmark(n==1); return; case WM_LBUTTONUP: lf2=0; if (dragmove==2) { ed_cmd(drag==3 ? EK_DRAG_COPY : EK_DRAG_MOVE); SetCursor(hCurs); } else if (drag) unmark(); drag_cancel: mf2=drag=dragmove=0; settimer(hwnd,0,0); #ifndef MV_DandD ReleaseCapture(); #endif return; case WM_RBUTTONDOWN: #if 0 if (NULL!=ShortCut) { POINT pt; GetCursorPos(&pt); TrackPopupMenu(ShortCut,TPM_CENTERALIGN|TPM_RIGHTBUTTON, pt.x, pt.y ,0,hwnd,NULL ); return; } #endif #ifdef NOCAPT SetCapture(hwnd); mox=(short)LOWORD(lParam); moy=(short)HIWORD(lParam); wmf=1,mux=mox,muy=moy; #endif return; case WM_RBUTTONUP: #ifdef NOCAPT wmf=0; if (NULL==ShortCut) ReleaseCapture(); #endif return; } }