If my program asks a user to input a file name and then check if that file exists, would I have to use an if statement to see if that file is able to open?
Something like this:
if(FILE_1 =...
Type: Posts; User: november1992
If my program asks a user to input a file name and then check if that file exists, would I have to use an if statement to see if that file is able to open?
Something like this:
if(FILE_1 =...
I came up with the idea after I posted the original code. But i realized I included parts of the code that skipped into the if statement. It works now.
I write void main because that's what my...
Cool, it works now! Thanks.
Although, I'm curious why my idea didn't work. I used strcpy to put argv[2] into a temp and then use isdigit on the first element. If isdigit returned 0, it printed...
Could I use strlen to figure out how long the input is and then use isdigit to check the first element?
#include <stdio.h>
#include <stdlib.h>
#define MAXCHAR 256
void main( int argc, char *argv[])
{
int fibonacci(int n);
My program calculates the first n numbers of the fibonacci series. For error checking, I've prevented the program from trying to calculate a negative number, but I'm having trouble with character...
That would be easier, but it was supposed to be singly linked not doubly.
well it didn't work out the way i had hoped. I'll just ask my professor.
I was wondering how to find the previous node in a singly, circular linked list.
In this picture I have 4 nodes.
http://i.imgur.com/hlvzT.png
If I wanted to get rid of the node Sarah, I would...
I'm not sure why this isn't working. It increments i by 1 until it finds the element that contains the '.' character. Then it adds '_out' to the location before '.'. I do get warnings before it...
I was thinking about using a for loop to compare the character '.' with the contents of a char array holding the name of the file. I would use the strcat function to add the _out.txt part to...
I have a question, how can I make an output file that takes the name of the input file and replaces the .txt extension with "_out.txt"?
For example, an input file with the name “test.txt” would...
I remember my TA telling me this too. I'm forgetful :p. thanks it scans now.
I tried using temporary variables, but now my program crashes.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXSIZE 256
I asked my TA whether to use 3 or EOF and he just told me to use EOF. But I'll just use 3 because it makes more sense to.
So here is my code so far. At the fscanf part it reads the contents of the...
My teacher says that he will test our program with a text file. He never said how many items there would be in there, he only said it would be different for everyone.
I can't use any functions we...
What if I don't know the number of items that need to be scanned? Shouldn't I use EOF then?
void main(void){
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXSIZE 256
I'm having a hard time using pointers because I don't understand them that well. When is it correct to use the * and & operator and what do they do?
I wrote two programs to switch the order of an array. I wrote them in the same way, but only one of them works correctly. Could someone tell me what is wrong?
Oh I just figured out the problem :p...
You said string2 is converted to a pointer to its first element, so what is that value? And how does it find the position by subtracting from find_c?
i = find_c - string2;
printf("The...
My professor wrote this program below. I was wondering why the find_c variable always changes when I run the program. Also, I'm confused about this line
i = find_c - string2;
"i" is the...
I'm just curious, what is wrong with using void main()? He never really explained the point of returning values.
Okay, I tested it now and it works. Thank you for the help.
Oh, I didn't think about that. So is this right?
#define NUM_ELEMENTS 7
int find_smallest (int x[], int y)
{
int i,small;