Hot answers tagged

2

Use a while loop to keep going through all of the characters (using fread) until end of file, and check if the char is a digit. If it is a digit, append it to your variable to hold the number and go on to the next char. If it is a space, load the previous number into your array or linked list and go on to next char. Same thing for \n.


2

The path name for the cs50.h header file is /usr/include/cs50.h. The path name for the cs50.c source file is /usr/src/cs50.c.


2

cs50.h goes here /**************************************************************************** * cs50.h * * version 1.1.6 * * Computer Science 50 * Glenn Holloway * David J. Malan * * Declarations for the CS50 Library. * Based on Eric Roberts' genlib.h and simpio.h. * * The latest version of this file can be found at * http://www.cs50.net/pub/...


2

Do not type the prefix "~/ $ ", just start with mkdir. For example, here you can see the wrong way, followed by the right way to do this:


1

To delete, navigate to the parent folder (aka directory) of what you want to delete in the command line (cd [folder name] to go down a level, cd .. to go up a level), then enter rm [filename], including any extension in the filename, to delete that file. You'll be asked whether you really want to delete it; enter "yes". Or right-click on the folder ...


1

This sequence = sequence_o.read doesn't execute the read function. It declares sequence as (basically) a copy of the read function. When a function does not take arguments (as with read), one must use read() to execute the function.


1

A FILE pointer is a pointer to a struct. That struct contains numerous elements. (You'll learn about structs later, if you haven't already.) This particular struct is defined in stdio.h as follows: typedef struct { short level ; short token ; short bsize ; char fd ; unsigned flags ; unsigned char hold ; unsigned char *buffer ; unsigned char * ...


1

In a for loop we have three well differentiated parts, the initialization, the end of cycle condition and the counter that changes the variable in each pass of the cycle, these three parts are flexible enough, and they are not all obligatory (you need to read a bit about it) ), in any case these three parts are separated by a semicolon. In your case it seems ...


1

Remember that you need to make a new file to write the images two. It looks like you successfully open card.raw, but all you do is name it in your for loop. You probably want to first read from your file to some sort of buffer that is 512 bytes long. Why? Because you know that each jpeg is sectioned into blocks each using the FAT system explained in the ...


1

FILE* img and FILE *img are the same, you must have been observing some other effect. While I like grouping the * with the type, as the type of img is FILE*, there's also the argument that you might have several variables on one line, like int* a, b;, which is equivalent to int *a, b;. The first one is misleading, as in both cases, a is a pointer, b is not. ...


1

In the appliance, you could right-click the pset1 folder and select "New File", or you could change into the pset1 folder in your console, and write touch hello.c, touch by default sets the last-accessed date on files, or creates them if they don't exist.


1

Supposing that before the loop you declare the file where you will write data FILE *jpgfile = NULL; You can use if (jpgfile != NULL) to check if you have an already open file.


Only top voted, non community-wiki answers of a minimum length are eligible