as in
cin.getline(tmp,100,'\n');
?
or can i bypass the buffer and go with
Type: Posts; User: SpEkTrE
as in
cin.getline(tmp,100,'\n');
?
or can i bypass the buffer and go with
i trying to read a line of users input and store that information. My problem is that when the data is being read it has a problem with the spaces.
struct link_list
{
char...
First off, please excuse the fact that there is some syntax of C in here...(i'm trying something)
I'm trying to read a line of data, that the user enters, and then store it into a linked list...
...
I'm having an error when using a linked list. I'm simply trying to have a list where you can create...add...delete..etc...
But in my case statement I receive.....
initialization of 'l1' is...
void alpha(struct employee *records);
...
main()....
....
void alpha(struct employee *records)
{
for(int n=1; n<= 13; n++)
I'm having trouble with my swap. I'm just trying to compare strings and swap them.
for(int n=0; n<= 13; n++)
for (int i=0; i<= 13; i++ )
{
int j=i+1;
...
yes you are right, I was tweaking numbers around and never changed that one...thanks
oh boy... :(
for (i=0;i<=14;i++);
do{
fgets(tmp,200,fPtr);
sscanf(tmp, "%d %s %f %d", &records[i].id, &records[i].name, &records[i].pr, &records[i].csalary);
}
yes I know, our teacher says he doesnt matter what we code in. So the headers are basically a default for most programs...
I compile my program and it compiles fine...but when I run it..I come up with zero's for all integers and blanks for strings...
can anyone see anything wrong? I at my wits ends and now wondering...
I've moved the fgets and the sscanf into my main function...but I'm still having zeros as output...
main()
{
char buf[100];
struct employee records[14];
int i=0;
FILE *fPtr;
If the file has been succesfully opened the function will return a pointer to the file. Otherwise a NULL pointer is returned
i.e.
return fPtr;
:rolleyes: ?
I'm almost there...
But I believe it is not reading the data from the first file. Mainly because I have output of zero's. I did try to place a print statement just after the fgets and the...
calm down there killer..i just didnt want to post the whole code...but here it is..
FYI: trail.txt is a file that consist of employee's
...
struct employee
{
int id;
char name[10];
float pr;
int csalary;
int raise;
double rate;
int nsalary;
};
that seem to have worked, now I have another error..
error C2228: left of '.csalary' must have class/struct/union type
from here ..
I'm having this error occur and I'm not sure how to resolve it...
error C2664: 'readfile' : cannot convert parameter 1 from 'employee [14]' to 'int *'
here is where it is pointing to...
i was thinking of using this...while it is still reading...
int i, pass, hold;
for (pass = 0; pass <=13; pass++)
for (i=0; i<=11; i++)
if (records[i] >...
I believe I'm with you so far...
fgets(buf,200,fPtr);
sscanf(buf, "%d %s %f %d", &records[i].id, &records[i].name, &records[i].pr, &records[i].csalary);
is it safe to...
isnt that this...
struct employee {
int id;
char name[10];
int pr;
int csalary;
int raise;
double rate;
now that I have the reading of the file done... How can I arrange alphabetically by name?
//#include <iostream>
#include <stdio.h>
//using namespace std;
understood!
Now I see that the my char buf will hold for example the first line...
now I need to use sscanf to break that line up into variables? i.e. id, name, pr, salary?
fyi:
here is...
I think I understand why I should not use fread, thanks
And I know fgets reads an entire line...but how would I write that?
fgets(?,100,fPtr);
:confused:
ok gettin back to the core of the problem...
why is this not showing any output? :confused:
//#include <iostream>
#include <stdio.h>
Hello all
I need some help with my program. Here is the jist of it. I need to write a program that pulls data from another (i.e. employee id, name, performance rating, and current salary)
...