struct StaffRec
{
char *fname;
char *lname;
};
typedef struct CDRec *StaffRecPtr;
staff createStaff(char *fname, char *lname)
{
Type: Posts; User: EeeK
struct StaffRec
{
char *fname;
char *lname;
};
typedef struct CDRec *StaffRecPtr;
staff createStaff(char *fname, char *lname)
{
to get a user array of string input?
printf("Title: ");
scanf("%[^\n]", title);
while(fgetc(stdin)!='\n');
if no, can you advise what are the ways to get an array of string, eg. "C...
In dereferencing a struct pointer, I do this in or outside of an implementation file:
x->name;
In dereferencing a void struct pointer, I can do this in a implementation file:
...
Solved the above by using %[^/n] and while(fgetc()!='\n');.
Here's one for understanding:
char x[3], *y;
y = (char*)malloc(sizeof(char)*3);
Is there anyway to use scanf() to get a string input with space?
Tks, quzah, solve the problem with that.
How do I change an int variable to a string variable? Using cast? Is this the way or there's something wrong with my code?
char line[99] = "A";
int...
Thx Dave_Sinkula, I got the display workin....
Here's a new one, why does the gets() in the following code accept any inputs? The program simply skip thru it. I tried using fgets() and it's give...
while(i!=NULL)
{
printf("%s\t%s\t%d", x, y, z);
i = j->next;
}
display:
friend chris 124
classmate mary 321
Ok what is the difference btn
char *x;
x = (char*)malloc(sizeof(char)*9);
and
char x[9];
So they are basically the same. So can I use the first and the second for fgets()? Because the middle arguments of fgets() is the buffer size. which is not define if I'm using the first and second.
...
What is the difference btn these 3:
char* text;
char *text;
char text[99];
The second is a char pointer and third is an array, so what is first? Can I use all of them for fgets() or only...
Yup, found out abt that but u post b4 I want to delete the post. Nonetheless thx for the reply.
Y does I get a passing arg 2 of 'fputs' from incompatible pointer type error at the fputs() line?
define FILENAME "x.txt"
.
.
.
fp = fopen(FILENAME, "a");
if(fp==(FILE*) NULL)
while (cout << "Enter a number: " && !(cin >> input))
{
cout << "\nInvalid input" <<endl;
cin.clear();
cin.ignore(std::numeric_limits < int >::max(), '\n');
}
cout <<"You...
If I entered "run.exe x.txt" in the following code, y does the if statement is always true?
int main(int argc, char *argv[])
{
if(argv[1]!="x.txt")
{
printf("\nPlease enter run...
Hi I've this string tokenizer assignment problem. I want to do this by myself but juz need some advise to get started.
Given a header file with these function protoypes:
typedef struct...
Got a prob that need some advise here, if I need to store a few thousands types using struct, say each type with 3 variables x, y and z?
How many I suppose to search for a certain type using only...
Y does the program keep looping when I enter a char as a input?
int main()
{
int x;
while(1)
{
If I've a ADT, and I've created a function in the main method to call the ADT, is that wrong? Coz I got this undefined reference compilation errors.
include <stdio.h>
include "adt.h"
void...
Hi guys, thx for fast replies, very much appreciated!!!
Give Brian a break, he's afterall have gd intention. :D
I've been getting compilation error: "parse error before xxx". What does it mean?...
Assuming the program name is "test.exe", why the if statement is not true when I enter "test hello"?
include <stdio.h>
int main(int argc, char *argv[])
{
if(argv[1] == "hello")
...