cs50

C - Undefined symbols for architecture x86_64 when compiling on Mac OSX Lion

不羁岁月 提交于 2019-11-30 01:28:18
问题 I'm getting some problems on compiling a very very simple name.c file on Mac OSX Lion. Now, I started following Harvard CS50 course on cs50.net. I'm not totally new to programming but I was curious on how this course has been taught. This is the source of name.c: #include <stdio.h> #include <cs50.h> int main(void) { printf("State your name:\n"); string name = GetString(); printf("O hai, %s!\n", name); return 0; } As you can see, it requires this library: https://manual.cs50.net/CS50_Library.

Creating a “Mario Style Pyramid” [duplicate]

雨燕双飞 提交于 2019-11-29 14:35:19
This question already has an answer here: Making a Hash Pyramid 2 answers I'm going through the Harvard CS50 online course and one of the problems is to create a "mario style pyramid" using spaces and hashes. I've got the spaces solved but the hashes are giving me trouble. Here's the code: #include <stdio.h> #include <cs50.h> int main(void) { //get height between 1 and 23 int height; do { printf("Please enter a height: "); height = GetInt(); } while (height < 1 || height > 23); //build pyramid for (int i = 0; i < height ; i++) { //add spaces for (int space = height - 1 - i; space >= 0; space--

Include an external library in C

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 07:06:21
I'm attempting to use a C library for an opencourseware course from Harvard. The instructor's instructions for setting up the external lib can be found here . I am following the instructions specific to ubuntu as I am trying to use this lib on my ubuntu box. I followed the instructions on the page to set it up, but when I run a simple helloWorld.c program using a cs50 library function, gcc doesn't want to play along. Example: helloWorld.c #include <stdio.h> #include <cs50.h> int main(void){ printf("What do you want to say to the world?\n"); string message = GetString(); printf("%s!\n\n",

What do .c and .h file extensions mean to C?

混江龙づ霸主 提交于 2019-11-28 03:11:37
It's all in the title; super-simple I reckon, but it's so hard to search for syntactical things anywhere. These are two library files that I'm copying from CS50.net , and I'm wondering why they have two different extensions. Stefano Borini .c : c file (where the real action is, in general) .h : header file (to be included with a preprocessor #include directive). Contains stuff that is normally deemed to be shared with other parts of your code, like function prototypes, #define'd stuff, extern declaration for global variables (oh, the horror) and the like. Technically, you could put everything

Making a Hash Pyramid

一个人想着一个人 提交于 2019-11-27 23:24:13
Currently doing the CS-50 course and was wondering if anyone could help me with this. I'm supposed to create a program which will ask a user for a height between 1-23 (and continuously prompt the user until a valid answer is given) --- I was able to code that part. #include <cs50.h> #include <stdio.h> int main(void) { int height; do { printf("please give me a height between 1-23: "); height = GetInt(); } while (height < 1 || height > 23); } The do while loop seems to do what its intended. Now, the program, given the variable "height" now needs to create a pyramid of that height. The bottom of

Making a Hash Pyramid

社会主义新天地 提交于 2019-11-27 04:40:48
问题 Currently doing the CS-50 course and was wondering if anyone could help me with this. I'm supposed to create a program which will ask a user for a height between 1-23 (and continuously prompt the user until a valid answer is given) --- I was able to code that part. #include <cs50.h> #include <stdio.h> int main(void) { int height; do { printf("please give me a height between 1-23: "); height = GetInt(); } while (height < 1 || height > 23); } The do while loop seems to do what its intended. Now

What do .c and .h file extensions mean to C?

99封情书 提交于 2019-11-26 23:57:54
问题 It's all in the title; super-simple I reckon, but it's so hard to search for syntactical things anywhere. These are two library files that I'm copying from CS50.net, and I'm wondering why they have two different extensions. 回答1: .c : c file (where the real action is, in general) .h : header file (to be included with a preprocessor #include directive). Contains stuff that is normally deemed to be shared with other parts of your code, like function prototypes, #define'd stuff, extern

Include an external library in C

谁说我不能喝 提交于 2019-11-26 16:19:02
问题 I'm attempting to use a C library for an opencourseware course from Harvard. The instructor's instructions for setting up the external lib can be found here. I am following the instructions specific to ubuntu as I am trying to use this lib on my ubuntu box. I followed the instructions on the page to set it up, but when I run a simple helloWorld.c program using a cs50 library function, gcc doesn't want to play along. Example: helloWorld.c #include <stdio.h> #include <cs50.h> int main(void){