Hey, for my Systems Programming course this semester, our prof has given us an assignment to create a Unix search program in C. Essentially, you give it a file name, go through each file, compare...
Type: Posts; User: Acolyte
Hey, for my Systems Programming course this semester, our prof has given us an assignment to create a Unix search program in C. Essentially, you give it a file name, go through each file, compare...
(Back again, yes I know...)
Anyways, for my current program, the last bit involves saving an inputted structure to a sequential text file, then loading it again later.
Here's the current save...
Part of my current program involves searching for spaces in a string and replaces them with underscores. Here's the current function:
void spacereplace()
{
int cnt, cnt2;
for...
That's not there anymore, it's been changed to actually work.
Well, the fflush seems to be working for what I need it to do, and that's to get rid of the newline read in from the menu.
However, I still can't get it to read in the last section. Here's what...
Gah, sorry, those are all stupid proofreading mistakes, stuff I forgot to nuke from prior fixing attempts.
Salem, I couldn't find anything in the FAQs about fflush-what should I be using?
...
I'm working on an assignment that takes some inputs for an address book. However, I have problems getting the input to read properly. Here's the section so far:
char addcontact ()
{
auto...
Ah, that did it Mats. Thanks, I knew it was some silly little mistake that I just needed a second set of eyes to get.
Sure.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
/*int replace (char wordlist[][100], int repnum);*/
Part of a program I'm working involves searching through an array of char and, if it finds a digit, converting it to int. Here's the section of the program doing that:
for (cnt = 0; cnt < wordcnt;...
What I was trying to do there is have it tokenize until it reaches a '0' in the string (The string will consist only of alphanumeric characters).
Ok, new problem. The old one was just me being stupid and unobservant.
#include <stdio.h>
#include <string.h>
int main ()
{
char wordlist[100][100];
I'm trying to work on a program that takes a string as an input, parses it into words according to spaces and newline characters, puts each word in its' own space into a char array, then prints the...
EDIT: NVM, found the problem.
Damn-that's something I hadn't considered. How would I go about dealing with multiple-digit numbers, then?
Changing it to
i = atoi(&input[cnt2]); removed the error, but it's still not working. Here's the whole section:
for (cnt2 = 0; cnt2 < 30; cnt2++)
{
...
Part of my current assignment requires reading input from a file (Using I/O redirection) into a string of char, then parsing it, converting the numbers to int and saving that to an array of int....
So, how would I convert '-' and '1' to an integer? Or, rather should I change it to just
while ((c = getchar()) != '-'), since the only reason a '-' would occur would be to denote the '-1'?
Ok, here's what I've got. As per my assignment instructions, it actually just uses I/O redirection. However, I'm having some errors:
#include <stdio.h>
char input [30];
int stack [30];
char c;...
How should I go about having it so it picks up where it left off after sorting each line? I was thinking something along the lines of this:
While (!= EOF)
fgets (numbers, converts to int, puts it...
For an assignment in my C course, I need to write a program that reads lines of numbers from a file, sorts them, writes the output to a file then reads the next line and continues, until a -1 is...