Python/C API can't import urllib2 library

I have to parse a HTML url and return a list of url to use a recursive method of parsing. I'm using BeautifulSoup on Mac OS and I have a problem to import html_parser.py html_parser.py : #!/usr/local/bin/python2.7 from bs4 import BeautifulSoup impo...
more »

2017-02-22 20:02 (0) Answers

C rand() is not random even when seeded

This is most likely a machine dependent issue but I can't figure out what could be wrong. #include <stdio.h> #include <stdlib.h> #include <time.h> int main(int argc, char** argv) { srand(time(NULL)); int r1 = rand(); int r2...
more »

2017-02-22 00:02 (2) Answers

Symbol used in printf

I was wondering what the symbol used in printf means. I tried googling but couldn't find the right name for it And here's the statement in question represented using the Unicode BOTTOM SQUARE BRACKET character, U+23B5: printf("⎵%d\n", br); (Thi...
more »

2017-02-21 19:02 (3) Answers

How to model random variables?

I want to know how to model random variables using "basic operations". The only random function I know, at least for C, is rand(), along with srand for seeding. There probably exists packages somewhere online but lets say I want to implement it on my...
more »

2017-02-21 13:02 (1) Answers

Does this self-assignment do something sensible?

I just found this line of code within a function, which puzzles me. Can this make sense in any context or it is undefined behavior? char * acFilename = acFilename; EDIT: The compiler complains with Warning C4700, that I am using an uninitialized v...
more »

2017-02-21 12:02 (4) Answers

Goto to VLA scope

Is this allowed? goto inside; { inside: int a[n]; } A goto statement shall not jump from outside the scope of an identifier having a variably modified type to inside the scope of that identifier. What about the inverse? { goto outside; i...
more »

2017-02-21 05:02 (2) Answers

Why is variable being mutated in C program?

While working through exercise 3-5 in The C Programming Language, I've come across the following unexpected behavior. #include <stdio.h> #include <string.h> // inspired by: http://www.eng.uerj.br/~fariasol/disciplinas/LABPROG/C_language...
more »

2017-02-21 05:02 (2) Answers

C to MIPS conversion. Array load word offset?

I have a C code that I need help with in MIPS. The C code is as follows. for (i=0; i<100; i++){ a[i] = b[i] + c[i] - d[i]; } I have converted this to MIPS but don't know what to put into the offset of load word. addi $t0, $zero, 0 ...
more »

2017-02-21 02:02 (1) Answers

Strict aliasing and overlay inheritance

Consider this code example: #include <stdio.h> typedef struct A A; struct A { int x; int y; }; typedef struct B B; struct B { int x; int y; int z; }; int main() { B b = {1,2,3}; A *ap = (A*)&b; *ap = (A){10...
more »

2017-02-20 20:02 (1) Answers

Matching an exact word using in c

Can I use the strstr function to match exact word? For example, let's say I have the word hello, and an input string line: if char* line = "hellodarkness my old friend"; and I use result = strstr(line, "hello"); result will match (be not NULL...
more »

2017-02-20 20:02 (3) Answers

Need help fixing my e^x approximation c program

I have written a c program that should compute and print the approximation of e^x for all values up to n. I am using this equation to implement my program. f(x, n) = e^x = the sum of i=0 up to n= x^i/x! = x^0/0! + x^1/1! + x^2/2! +....+ x^n/n! ...
more »

2017-02-20 17:02 (2) Answers

%c keeping new line char in while loop, fix?

/*Title: P3.c Location: ~/csc1710/P3/P3.c Class: CSC1710 Name: Emily Date: 02-18-2017 This program is meant to convert a colored image to black and white.*/ #include<stdio.h> #include <string.h> int main(void) { int height, width; ...
more »

2017-02-20 15:02 (2) Answers