#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int arraySize[argc-1];
int i;
if(argc < 2)
{
Type: Posts; User: mapunk
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int arraySize[argc-1];
int i;
if(argc < 2)
{
lol, thanks...don't know why i didn't think of that
Yeah, it took out all the spaces/tabs and what not, but it was getting a bunch of other random data from other parts of the memory (which is b/c its not terminating when it should) But, I thought...
how come this doesn't work for me?
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAXSIZE 80
then could you just do this:
while(fgets(item, 25, inputfile) != EOF )
{
if (!strcmp(item, "End of file"))
{
printf ("\n%s", item);
}
is it always going to be: something AND something? As in, apples and oranges, or grapes and plums, or is there a possibility there will be more than 3 words?
would this work?
while (!strcmp(fgets (item, 25, inputfile)), "End of file")
{
printf ("\n%s", item);
}
i went with the atoi...thanks for the help
I have an array, lets call it buffer.
buffer[0] = 9
buffer[1] = 2
buffer[2] = 3
how would i get a variable, x, to equal 923 (not only those numbers, but the contents of the buffer, whatever...
no b/c i'm going to be reading in different files, so i can't initialize the array to anything
Yeah that's my problem, I dunno how to assign say buffer[0], buffer[1], and buffer[2] to one array value instead of three. What should I do?
I'm incrementing the buffer (i) and the column (k) whenever I find a number. I increment the row (j) at the very end, when the first while loop has to go to the top again.
I'm reading in this file:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7...
try putting this into a program, and experimenting with it:
fgets(buffer, 10, stdin);
printf("%s", buffer);
you'll notice that you're right on all conditions.
EDIT: nevermind, I didn't see that you made the function a pointer...I didn't catch that. Thanks for the help. It worked :)
And thanks about that #define thing...i just wrote that quickly in...
what's wrong with this? I get this error: The error refers to the red line.
(in my header file)
#define MAX_TEST 80;
typedef struct {
second question. I'm reading a line such as this:
200 100
how would i go about setting the first number to the image height and the next to the width?
I know this isn't right....at all,...
ahh thanks. And i know about the file name, I actually have a variable there, but changed it just so it was easier to interpret...just forgot the quotes when i changed it
hmmm I copied your code and made it into a main function so I could run it, and its working fine. I added some printf's so i could see if it was working correctly, and it seemed to be. here's the...
I'm making a program that has to read in and manipulate a pgm file. I need to make sure the first line in the file is P2, not P5. How would i go about doing this?
so far i have something like...
strlen and strcpy...they're in both strings.h and string.h
k so now i have this code, and when I try to input the information, it only allows me to enter the planet.name once, but i can enter...
ohh thanks. didn't see that missing &. And yeah, it needs to be <= 8 so it includes the 9th planet. Thanks alot, I"ll try those out. And why can't it be strings.h? I've never used string.h....
I've always used strings.h in my class.
But that's not relevant, b/c i haven't put in the code yet that needs strings.h. I didn't use my MAXSIZE either...
I read the rules, and no i'm not asking anyone to do my homework...I want to know what i'm doing wrong with these structure arrays. I've tried to figure it out but i still can't get it. Here's the...