18 Archived Topics
Remove Filter Similar to echoserver, but this one handles multiple clients by forking the process. | |
This is a simple echo server that I've written while learning sockets programming. Compile the server and run it. You can connect to it using telnet like this: telnet localhost 1337 Disconnect the client by typing "/quit" without quotes. | |
This is a simple hangman game that I wrote using my beginner python skills. Though this game is playable, there must be lots of things I must've been doing wrong or the methods I'm using here may be not so pythonic. So I want some suggestions on how to improve … | |
If there's a list like below [CODE]s=['b','a','r','r','i','s','t','e','r'][/CODE] and if I tried to remove every 'r' from the list like this [CODE]>>> for x in s: if(x=='r'): s.remove(x)[/CODE] it gives the following result. [CODE]>>> s ['b', 'a', 'i', 's', 't', 'e', 'r'][/CODE] Why isn't the last 'r' removed from the list. | |
I wrote a procedure to read integers(unsigned) from stdin and store it in a variable. I wanted it to handle backspaces too. so I made some adjustments but unfortunately it didn't work.--see line 14 in the code [CODE]get_num: ;(function get_num: read integers from stdin) push ax ;save all registers push … | |
Alright, here's the deal.There's a folder with Jpg images and I want to open each JPG image in that folder, rotate it clockwise once and save it with the same name in the same folder. How do I do that with batch programming? We Can't use "Windows Picture and Fax … | |
[CODE] .MODEL small .STACK 100h ; defines a stack 100h (256) bytes long .DATA String DB "Hello World!",'$' ; variable declaration .CODE Start: mov dx,offset String ; point dx to the storage location for the first character mov ah,9 ; dos function for string output int 21h Stop: mov ax,4C00h … | |
I'm Using [ICODE]fwrite[/ICODE] to print the contents of a sturcture in a file. [CODE] #include <stdio.h> #include <stdlib.h> struct com{ int code; char* name; }; int main() { struct com py[2]={{21,"Monty Python"}, {22,"Python lang"} }; FILE * fp; if((fp=fopen("data.txt","w+"))==NULL) exit(1); fwrite(&py,sizeof(struct com),1,fp); /*int i; for(i=0;i<2;i++) fprintf(fp,"code:%d,name:%s\n",py[i].code,py[i].name); */ fclose(fp); return 0; … | |
I am trying to write a program for searching strings(one at a time)in a text file. To start things off, I wrote this one. [CODE] #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> int main() { FILE *txt_file; int chr;/*char read by fgetc*/ int word_match=0; const char* substring ="window";/*search word*/ … | |
Here's a code to find out if the number is palindrome or not. [CODE] #include <stdio.h> int main() { int num,chknum1,chknum2=0,i,rmndr;/*here rmndr is remainder after mod,chknum is reversed num*/ printf("enter the number"); scanf("%d",&num); chknum1=num;/*saving num,since it is manipulated*/ for(i=0;i<=sizeof(chknum1);i++) { rmndr=num%10; num=num/10; chknum2=chknum2*10+rmndr; } printf("chknum1 %d,chknum2 %d",chknum1,chknum2); //if(chknum1=chknum2) //printf("Is palindrome"); … | |
[CODE] #include <stdio.h> float pows(float,float); int main() { float num,base; printf("enter base followed by power integer."); scanf("%f %f",&base,&num); printf("%f ",pows(base,num)); return 0; } float pows(float base,float n) { if(n==0) return(1); else if(base==0) return(0); else for(;n>=1;n--) { return(base*pows(base,n-1));/*recursive*/ } } [/CODE] | |
I'm trying to embed python script in c in windows. [CODE] #include <Python.h> int main(int argc, char *argv[]) { Py_Initialize(); PyRun_SimpleString("from time import time,ctime\n" "print 'Today is',ctime(time())\n"); Py_Finalize(); return 0; } [/CODE] from the python documentation. I'm compiling with Microsoft's lcc. I'm getting following errors. Error c:\lcc\examples\python\pyembed.c 7 undefined reference … | |
I'm trying to convert hexadecimal values to Binary. I've done Decimal values to Binary up to 32 bits in this way: [CODE] #include <stdio.h> int showbits(int);/**************function*prototype******************************/ int main() { unsigned int num; printf("enter the number."); scanf("%d",&num); printf("%d in binary is ",num); printf("\n"); showbits(num);/*********************function*call********************************/ return 0; } showbits (int n)/******************function*definition****************************/ //* … | |
I've been trying to automate the creation of a user account with admin rights using cmd bat . [CODE] net localgroup administrators [I]account name[/I]/add [/CODE] got the following error: [CODE]There is no such global user or group:[I]account name[/I][/CODE] what's the problem? | |
make failed Error: Error: Unresolved external '_main' referenced from C:\BC5\LIB\C0X32.OBJ I got above error when trying to build one of the examples given in \BC5\examples directory.What is the cause? | |
[CODE]def nod(n): c,i=0,0 while n>0: c=n%10 if c!=0: i=i+1 n=n//10 print(i)#prints the number of digits in the given integer 'n' [/CODE] how to make it able to count 'zeros'? | |
I was using winsound module for the first time to use it on one of my small app,and it didn't even gave me a BEEP!. I imported winsound module first. [CODE] >>> import winsound >>> [/CODE] then [CODE]winsound.Beep(37,10)[/CODE]leads to nothing! Any kinda help is appreciated. | |
The End.