So I've replaced '\r' and '\n' with '\0'. This, however, just fills up the file with 0s instead of just removing the contents all together. I would like to just fill the '\n' with nothing, not even...
Type: Posts; User: ImageJPEG
So I've replaced '\r' and '\n' with '\0'. This, however, just fills up the file with 0s instead of just removing the contents all together. I would like to just fill the '\n' with nothing, not even...
Got it.
Sorry, I'm difficult sometimes. :/
//
// main.c
// number_guess
//
For example, if I place 10000 inside of the buffer, it's fully populated because of '\n' at the end.
This isn't happening though for whatever reason.
Any ideas? I can't execute the clear buffer instruction because fgets never fully populates its buffer. If I execute the clear buffer functions before fgets populates its buffer, the clear buffer...
Also, so I don't have to keep posting my modified code:
GitHub - e14tech/number_guess: A random number guessing game
Wow, I feel really dumb not using return 1 :/
Like this:
15322
Also, I know using goto is frowned upon but I've read where situations like nested loops are acceptable.
I'll have to give that a shot.
IIRC, if you use fgets and stdin goes over the fgets buffer, the excess characters stay in stdin and are read when another call to fgets is executed.
That's why...
I'm using the while((c = getchar()) != '\n' && c != EOF); method but if it's called, it goes into an infinite loop.
If the character array goes over 10, including '\n', it gets stuck in an...
I've been doing a bit more work with it. It seems to be fully working.
And for full context, this will force a user to enter a number. If the user enters a series of numbers but adds a non-integer...
And sorry, I should have provided more context. I am printing the index locations of found numbers to help me figure out if it's working or not.
When you say convert the input to an integer, do you mean instead of "char UserInput[64];" I use "int UserInput[64];"?
Right now, it just reports back where a number is located within the UserInput array.
AFAIK, isdigit only works on int types. I'm taking input as chars.
The way my code is right now, if I used...
DOS C compiler on DOSBox maybe?
Install Turbo C++ Compiler on 64-bit Windows 7 Using DosBox - techinfoBiT
ibiblio.org FreeDOS Group -- Development
IMO, go after the stuff listed in the...
I'm developing a function to determine if a user has entered a number or characters.
Here's the code for that:
#include <stdio.h>
#include <string.h>
#include <stdint.h>
It’s “C Programming” by Wikibooks on iBooks.
I’m currently reading on math.h
I was horrible in math, worse in algebra in high school, I’m just as bad today almost 10 years later.
...
Are you able to tell me some of the functions used in your function without giving away how it works?
I've done a bit more work. This time I can accept characters (except for the looper variable, haven't done that yet). My goal is to just reject anything that's not a number. I'll get there.
Here's...
I'm on my way to make a Hang Man game so I thought I'd develop a random number guessing game first.
Here's the code:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
Oh, I was thinking it worked similar to getc where it grabs the next character each time the loop is iterated.
So it's just a matter if adding:
if(ep == NULL)
break;
Wouldn't dp have to become null to give ep a null value? If that's the case, wouldn't the while loop terminate itself since it depends on dp != NULL?
For your error output, I would recommend either perror("enter your msg here\n") or fprintf(stderr, "enter your msg here\n")
Another recommendation would be to rename your variables into something...
Oh, and this is from GNU's own site
The GNU C Library: Simple Directory Lister
I've been looking at some code to print out the current directory the executable is located.
Here's GNU's code for a simple directory listing program:
#include <stdio.h>
#include...