#include%26lt;stdio.h%26gt;
struct account
{
int accno;
char acctype;
char name_accholder[10];
float balance;
}s1,*pt;
main()
{
pt=%26amp;s1;
puts("enter accno type name of acc_holder balance");
scanf("%d%c%s%f",%26amp;pt-%26gt;accno,%26amp;pt-%26gt;acctype...
%26amp;pt-%26gt;name_accholder,%26amp;pt-%26gt;balance);
printf(" accno %d acctype %c name %s balance %f", pt-%26gt;accno,pt-%26gt;acctype,pt-%26gt;name_accholder...
}
How to read a char type structure member properly? the code below is not working properly.?
Do one thing try removing the "%26amp;" symbol from the scanf statement. Check if that is making any difference. I am doubting on that only.
Reply:scanf("%d %c %s %f" ,%26amp;pt-%26gt;accno,%26amp;p...
this will solve your problem the spaces between the formatters will help scanf to recognise the input correctly else it takes the last key stroke(enter key) as an input for %c and crashes.
Reply:Be clear in ur ques. Is the char acctype is not printed properly or the name_accholder array?
Let me know the output which you got...
Tuesday, July 28, 2009
The following statement as under plz tell me the answer?
a) the following statement
struct customer *ptr = malloc( sizeof( struct customer ) );
Given the sample allocation for the pointer "ptr" found above, How I can write a statement to reallocate ptr to be an array of 10 elements?
b) the following diagram that shows the possible connection between a pointer dp and the dynamic variable associated with it.
How we can Write c++ statements that generates code for this diagram any one can tell me.
The following statement as under plz tell me the answer?
Sorry, but I have no idea what in the world you might be babbling about.
Reply:Im sorry to waste more space like the guy above me, but I just wanted to say that the morons around these 'Q and A's' can't help you with any thing that doesnt involve 'going to the bathroom' or 'why my kid keeps crapping on the floor'. Instead you get guys like the one above me who just comes in here to waste peoples time and space to get some STTTTUUUUUPPPPIIIIIDDDDD points. Sorry I cant help, but I would suggest googling ''C++ forum'' or something along those lines
struct customer *ptr = malloc( sizeof( struct customer ) );
Given the sample allocation for the pointer "ptr" found above, How I can write a statement to reallocate ptr to be an array of 10 elements?
b) the following diagram that shows the possible connection between a pointer dp and the dynamic variable associated with it.
How we can Write c++ statements that generates code for this diagram any one can tell me.
The following statement as under plz tell me the answer?
Sorry, but I have no idea what in the world you might be babbling about.
Reply:Im sorry to waste more space like the guy above me, but I just wanted to say that the morons around these 'Q and A's' can't help you with any thing that doesnt involve 'going to the bathroom' or 'why my kid keeps crapping on the floor'. Instead you get guys like the one above me who just comes in here to waste peoples time and space to get some STTTTUUUUUPPPPIIIIIDDDDD points. Sorry I cant help, but I would suggest googling ''C++ forum'' or something along those lines
In the following statement ..............?
a) In the following statement
struct customer *ptr = malloc( sizeof( struct customer ) );
Given the sample allocation for the pointer "ptr" found above, write a statement to reallocate ptr to be an array of 10 elements?
b) Consider the following steps that shows the possible connection between a pointer dp and the dynamic variable associated with it.
1. Dp = 0045:02FE pointer Variable (Data segment)
2. *dp = 3.1415 dynamic variable (heap)
How I can Write c++ statements that generates code for these steps.
In the following statement ..............?
C++ Language Tutorial
http://www.cplusplus.com/doc/tutorial/
///
Reply:I didnt realize that this site was now used for HOMEWORK!! What a great idea?? Wish it was around when I was in school, maybe I would have gotten better grades, having someone answer my school projects!!!! You wont learn anything unless you actually do it yourself.
struct customer *ptr = malloc( sizeof( struct customer ) );
Given the sample allocation for the pointer "ptr" found above, write a statement to reallocate ptr to be an array of 10 elements?
b) Consider the following steps that shows the possible connection between a pointer dp and the dynamic variable associated with it.
1. Dp = 0045:02FE pointer Variable (Data segment)
2. *dp = 3.1415 dynamic variable (heap)
How I can Write c++ statements that generates code for these steps.
In the following statement ..............?
C++ Language Tutorial
http://www.cplusplus.com/doc/tutorial/
///
Reply:I didnt realize that this site was now used for HOMEWORK!! What a great idea?? Wish it was around when I was in school, maybe I would have gotten better grades, having someone answer my school projects!!!! You wont learn anything unless you actually do it yourself.
Pls help me?
i want file programe in c following Methods
pls sample programe
getc( fptr) à Reads a character from the file
putc (char, fptr) à Writes a character to the file
fputs (char[] , fptr) à Writes a line to the file
fgets (fptr, size, char[]) à Reads a line from the file
fprintf (fptr, “control string”, variable) à writes formatted input to the file
fscanf (fptr, “control string”, variables) à Reads formatted output to the screen
fread (struct variable, size of var, records , file ptr) à Reads a set of data like structure
fwrite(struct variable, size, record, fptr) à writes a set of data like structure
feof (fptr) à Checks whether we are at the end of the file or not
ftell (fp) à Tells the current cursor position
fseek (fp, (long) offset, position) à sets the cursor position
where offset à specifies the size of the cursor to be moved
position à 0 – from beginning
1 – from current place
Pls help me?
The input data for a program in real time always large and uses a large amount of data.The use of printf or scanf functions is not efficient programming as large input data reading becomes tedious .It is always advised to use files to store data on disks so it is never lost even if power is lost.There are quite good books like G.Balaguruswamy c.programming and let us c .......etc to start with .Use can easily know usage of commands with the sample program in those commands..............
online survey
pls sample programe
getc( fptr) à Reads a character from the file
putc (char, fptr) à Writes a character to the file
fputs (char[] , fptr) à Writes a line to the file
fgets (fptr, size, char[]) à Reads a line from the file
fprintf (fptr, “control string”, variable) à writes formatted input to the file
fscanf (fptr, “control string”, variables) à Reads formatted output to the screen
fread (struct variable, size of var, records , file ptr) à Reads a set of data like structure
fwrite(struct variable, size, record, fptr) à writes a set of data like structure
feof (fptr) à Checks whether we are at the end of the file or not
ftell (fp) à Tells the current cursor position
fseek (fp, (long) offset, position) à sets the cursor position
where offset à specifies the size of the cursor to be moved
position à 0 – from beginning
1 – from current place
Pls help me?
The input data for a program in real time always large and uses a large amount of data.The use of printf or scanf functions is not efficient programming as large input data reading becomes tedious .It is always advised to use files to store data on disks so it is never lost even if power is lost.There are quite good books like G.Balaguruswamy c.programming and let us c .......etc to start with .Use can easily know usage of commands with the sample program in those commands..............
online survey
Given the structure and pointer, what assignment statement sets the Price member of the structure pointed to?
by PC to 1000???????
struct Computer
{
char Manufacturer[30];
float Price;
int Memory;
} *PC;
int main (void)
{
struct Computer pc;
PC = %26amp;pc;
return 0;
}
a. PC-%26gt;Price=1000.0;
b. PC.Price=1000.0;
c. *PC.Price=1000.0;
d. Computer.Price=1000.0;
Given the structure and pointer, what assignment statement sets the Price member of the structure pointed to?
The answer is a).
PC is a pointer to a Computer.
To dereference a pointer, use -%26gt;.
Hence, the answer is PC-%26gt;Price = 1000.0;
You could also use (*PC).Price = 1000.0; however c) in the above example is wrong because it does not include brackets, which are required here.
struct Computer
{
char Manufacturer[30];
float Price;
int Memory;
} *PC;
int main (void)
{
struct Computer pc;
PC = %26amp;pc;
return 0;
}
a. PC-%26gt;Price=1000.0;
b. PC.Price=1000.0;
c. *PC.Price=1000.0;
d. Computer.Price=1000.0;
Given the structure and pointer, what assignment statement sets the Price member of the structure pointed to?
The answer is a).
PC is a pointer to a Computer.
To dereference a pointer, use -%26gt;.
Hence, the answer is PC-%26gt;Price = 1000.0;
You could also use (*PC).Price = 1000.0; however c) in the above example is wrong because it does not include brackets, which are required here.
Given the structure and pointer declarations below, which sets the Price member of the structure?
pointed to by PC to 1000
struct Computer
{
char Manufacturer [30};
floatPrice;
int Memory;
} *PC;
int main (void)
{
struct Computer pc;
PC = %26amp;pc;
return 0;
}
a. PC-%26gt;Price=1000.0;
b. PC.Price=1000.0;
c. *PC.Price=1000.0;
d. Computer.Price= 1000.0
Given the structure and pointer declarations below, which sets the Price member of the structure?
May you need to contact a C expert. Check http://k.aplis.net/
Reply:Well, I actually wrote out a legitiate answer to this question, assuming that it was an honest issue. However, after looking a bit longer at the questions page and seeing that every other question on the list was you asking another homework problem, I suddenly lost interest in helping you. Good luck with it, pointers can be a bit tricky.
struct Computer
{
char Manufacturer [30};
floatPrice;
int Memory;
} *PC;
int main (void)
{
struct Computer pc;
PC = %26amp;pc;
return 0;
}
a. PC-%26gt;Price=1000.0;
b. PC.Price=1000.0;
c. *PC.Price=1000.0;
d. Computer.Price= 1000.0
Given the structure and pointer declarations below, which sets the Price member of the structure?
May you need to contact a C expert. Check http://k.aplis.net/
Reply:Well, I actually wrote out a legitiate answer to this question, assuming that it was an honest issue. However, after looking a bit longer at the questions page and seeing that every other question on the list was you asking another homework problem, I suddenly lost interest in helping you. Good luck with it, pointers can be a bit tricky.
Can someone help me with client server error?
i am trying to complie this client.c using gcc -lsocket client.c
but i get these error:
warning: incompatible implicit declaration of built-in function 'bzero'
warning: incompatible implicit declaration of built-in function 'bcopy'
passing argument 2 of 'connect' from incompatible pointer type
warning: incompatible implicit declaration of built-in function 'strlen'
here is the code below:
#include %26lt;stdio.h%26gt;
#include %26lt;stdlib.h%26gt;
#include %26lt;sys/types.h%26gt;
#include %26lt;sys/socket.h%26gt;
#include %26lt;netinet/in.h%26gt;
#include %26lt;netdb.h%26gt;
void error(char *msg)
{
perror(msg);
exit(0);
}
int main(int argc, char *argv[])
{
int sockfd, portno, n;
struct sockaddr_in serv_addr;
struct hostent *server;
char buffer[256];
if (argc %26lt; 3) {
fprintf(stderr,"usage %s hostname port\n", argv[0]);
exit(0);
}
portno = atoi(argv[2]);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd %26lt; 0)
error("ERROR opening socket");
Can someone help me with client server error?
You have the same problem as this person:
http://www.thescripts.com/forum/thread21...
but i get these error:
warning: incompatible implicit declaration of built-in function 'bzero'
warning: incompatible implicit declaration of built-in function 'bcopy'
passing argument 2 of 'connect' from incompatible pointer type
warning: incompatible implicit declaration of built-in function 'strlen'
here is the code below:
#include %26lt;stdio.h%26gt;
#include %26lt;stdlib.h%26gt;
#include %26lt;sys/types.h%26gt;
#include %26lt;sys/socket.h%26gt;
#include %26lt;netinet/in.h%26gt;
#include %26lt;netdb.h%26gt;
void error(char *msg)
{
perror(msg);
exit(0);
}
int main(int argc, char *argv[])
{
int sockfd, portno, n;
struct sockaddr_in serv_addr;
struct hostent *server;
char buffer[256];
if (argc %26lt; 3) {
fprintf(stderr,"usage %s hostname port\n", argv[0]);
exit(0);
}
portno = atoi(argv[2]);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd %26lt; 0)
error("ERROR opening socket");
Can someone help me with client server error?
You have the same problem as this person:
http://www.thescripts.com/forum/thread21...
Subscribe to:
Posts (Atom)