This simple loop construct is confusing me. I'm not seeing why the output is what it is. When I look at the code it seems like this should print one set of statements with x going from 0 to 4. Like...
Type: Posts; User: mesmer
This simple loop construct is confusing me. I'm not seeing why the output is what it is. When I look at the code it seems like this should print one set of statements with x going from 0 to 4. Like...
I have a file with a bunch of records in it. From the file I need to fill an array of structures. I have to do this dynamically.
I'm having a hard time discovering how to fill an array of structures from a file. This is what I'm trying to do.
I am going to open a file from the command line. In the file are a bunch of...
I need to read a bunch of data. Some of it I know will not be in the format that I need. I know that fgets will read a file steam and pull in everything that is there until EOF and dump it in an...
This board has been very helpful to me and I really appreciate it. However, I'm stuck on a project and reading the book, asking on irc, and forums is not getting me any closer to seeing what I'm...
Wow, thx for the help.I give that a shot
I guess that I'm not sure where to call the macro: Here is the relevant code:
printf("Enter File Name: ");
scanf("%s",fileName);
printf("\n\n");
sp =...
That code works, I guess that my problem is that while the buffer gets flushed it stops reading from the buffer. I need to keep reading from the buffer until EOF
I'm not understanding how to discard unwanted data in a file stream. For example I want to read in a list of doubles and only doubles from a file, if a non double is in the stream, some text for...
I thought that the for loop in my code is incrementing or indexing though the data array
Ok, this is still not working. I've tried everything I can think of but still it's not working as it should. If I run the code I can print the contents of the file just fine,however, they are not...
char fileName[100];
int data[100];
FILE* sp;
sp = fopen(fileName,"r");
while(k=(fscanf(sp,"%i",data) == 1)){
printf("%10i\n",*data);
b += k++ ;
Oh boy, I thought that an array's name is a pointer to the first element in the array and that there is no need to place an ampersand in the fscanf function because of this. What am I not...
I must be making a simple mistake but I can't seem to find out what I'm doing wrong. Here is my problem: I'm reading data from a file into an array, but the values are only being written into the...
I'm having a little difficulty understanding how to read a file into an array - in this case a file of numbers (ints) into an array. I know how to open a file for reading, but once I have it open...
Thx for the responsse Salem,but is there an easier way to do this? I'm not that advanced in my skills yet.
Since there is no string type in C how do read in a string? For example:
I want to prompt the user for the name of a file. Using the name of the file I want to open the file.
Since I won't know...
Thanks, I see what's going on now! :)
int main(void){
FILE* spIn;
int numIn;
int ary[5];
int i;
spIn = fopen("rut.txt","r");
for(i=0;i<5;i++){
while((fscanf(spIn,"%d",&ary[i])) == 1)
printf("%d\n",ary[i]);
}
when I write a program that reads a file in to the stream where do I place the file?
Note: I'm using Ubuntu Linux
int main(void){
FILE* spIn;
int numIn;
spIn = fopen("rut.txt","r");...
The scanf function returns the number of characters it read correctly. So what you are doing there is setting i to 2 if scanf reads in two characters correctly.
Good quality responses,much appreciated:) So it seems I need to start checking out the Java libraries:cool:
Hey,
I'm studying C but my next language will be Java. I'm wondering - other than flow of control and data structures like arrays and pointers - how much of what I'm learning will carry over to...
Ok, I've seen make files in my IDE. Netbeans requires you to make a project for your code- in this project are several files-.c,make and a few others
I have a question about how "real" programs are created. I'm trying to understand C so i went to sourceforge and download a MUD (multi user dungeon) written in C.
When I looked in the .zip I noticed...