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.

Member Avatar
Member Avatar
+0 forum 4

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 bx push cx push dx mov bx,10d ;bx=10(decimal) xor dx,dx GNloop1:xor ax,ax mov ah,01h ;get the input from stdin int 21h xor ah,ah ;ah all clear! cmp al,0Dh ;check if the input was <return> je GNloop2 ;if yes then goto GNloop2 cmp al,08h ;check if BACKSPACE was pressed jne _continue_ …

Member Avatar
Member Avatar
+0 forum 1

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 viewer" for this right?

Member Avatar
Member Avatar
+0 forum 1

[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 ;exit dos int 21h END Start [/CODE] The output of this program is: [ICODE]I♦K☺I♦V☺I♦I♦☺☺☺ ☻               <♣Φ ë♣¶ ↑ w♣     ♣ ═!╦ ║♀ ┤ ═!╕ L═!Hello World![/ICODE] What am I missing here?Can anyone help me?

Member Avatar
Member Avatar
+0 forum 7

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; } [/CODE] It either prints nothing or prints some garbage. While the second method using[ICODE] fprintf()[/ICODE] seems to work.

Member Avatar
Member Avatar
+0 forum 3

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*/ int i=0; char word[15];/*to save the word read from the file)*/ if((txt_file=fopen("text.txt","r"))==NULL) { printf("Can't open the file\n"); exit(1); } while((chr=fgetc(txt_file))!=EOF) { word[i]= chr; i++; if(isspace(chr)||ispunct(chr)) { word[i-1]='\0'; /* printf("%s\n",word);/*testing! testing!*/ if(strcmp(word,substring)==0 ) { word_match++; } i=0; } if(isspace(word[i])) i=0; } fclose(txt_file); printf("Matched words:%d\n",word_match); return EXIT_SUCCESS; } [/CODE] This program has …

Member Avatar
Member Avatar
+0 forum 21

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"); //else //printf("is not palindrome."); return 0; } [/CODE] But it prints couple of extra zeros when the number is reversed,hence will fail to tell if the number is palindrome or not. Can anyone tell me what am I missing?

Member Avatar
Member Avatar
+0 forum 24

[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]

Member Avatar
Member Avatar
+0 forum 23

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 to __imp__Py_Initialize Error c:\lcc\examples\python\pyembed.c 8 undefined reference to __imp__PyRun_SimpleStringFlags Error c:\lcc\examples\python\pyembed.c 10 undefined reference to __imp__Py_Finalize I added python include files in the project.But I'm not sure what to do with py27.lib or py27.dll.That may be the problem I guess.

Member Avatar
Member Avatar
+0 forum 2

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****************************/ //* { int i,k,andmask; for(i=31;i>=0;i--) { andmask = 1<<i; k=n&andmask; k==0?printf("0"):printf("1"); } } [/CODE] Now I wan't to add hexadecimal values in it.

Member Avatar
Member Avatar
+0 forum 4

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?

Member Avatar
Member Avatar
+0 forum 4

I couldn't find a decent C network programming book for windows. Can anybody help me?

Member Avatar
Member Avatar
+0 forum 1

I want to run a program every time windows starts with a certain user's credentials . If i did that in bat file ,it will prompt for the user's password.How can i automate the insertion of password?

Member Avatar
Member Avatar
+0 forum 1

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?

Member Avatar
Member Avatar
+0 forum 4

using wx python.got black bars instead of unicode characters in gui window. [hint]:My interpreter gives error- [COLOR="Red"]Unsupported characters in input[/COLOR]

Member Avatar
+0 forum 0

[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'?

Member Avatar
Member Avatar
+0 forum 1

I used py2exe to make an executable,works fine.But even for a simple app I've got 18 other files(.pyd and dlls includinf pythonxy.dll) in the dist folder. I've heard that these files can be compressed into the executable using Gui2exe. I have Gui2exe installed already but haven't quite used it due to a problem. The problem is - in "gui"window of gui2exe the locations for python modules does not accept the given modules separated by commas i.e.(tkinter,zipfile,fnmatch...) Am i really a moron or what?!

Member Avatar
+0 forum 0

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.

Member Avatar
Member Avatar
+0 forum 8

Can anyone provide information on available gui c toolkits?

Member Avatar
Member Avatar
+0 forum 3

The End.