one thing that looks troublesome is this
student_t *myStudents[10];
to me, you have declared a 2d array. but then you write this
strcpy(course_t.myStudents[0].fname, "Bob");
Type: Posts; User: Brain_Child
one thing that looks troublesome is this
student_t *myStudents[10];
to me, you have declared a 2d array. but then you write this
strcpy(course_t.myStudents[0].fname, "Bob");
well if you need another clue, I wrote this program to help me determine the relationship
#include <stdio.h>
int main (void)
{
int array[3][4];
int i, k, j=0;
oh ok.
is this a common programming practice though?
i ask cause couple weeks ago I had to code up a BFS type algorithm on a grid represented as a string, and not a 2d array. it was painful...
the purpose of programming assignments is to give you a chance to learn the language through practice. your lecturer/tutor doesnt want a correct program for the sake of it. if they really wanted it...
im confused. how could you possibly get that output if you declare but dont initialise
here is the key line
while (getchar() != EOF)
what this means is the while loop (which just increments the counter by one) will continue as long as you do not enter the EOF character.
...
ah yes, only 19. the 20th spot is reserved for the null byte
fgets is what you should use
char *fgets(char *s, int size, FILE *stream);
eg
fgets(name, 20, stdin);
here is the fix.
int ch;
...
printf("No. Try Again. What is %d / %d = ? ", first, second);
while ((ch = getchar()) != '\n' && ch != EOF);...
firstly, you need to get the numbers from the user with something like
scanf("%d", &number);
secondly, your for loop doesnt do quite what you expect it to do
for (number1 = 1 ;...
you shouldnt try to work out this problem because your code is just poor and you should never have anything at all resembling that line in a real program.
why?
for the very reason that you are...
cant use fflush to clear the input buffer
Cprogramming.com FAQ > Why fflush(stdin) is wrong
see here
Cprogramming.com FAQ > Flush the input buffer
typedef struct {
char firstName[30];
char lastName[30];
char street[35];
char city[20];
char state[3];
int zip;
...
I've written some complicated code and I am in no way measuring the quality of this program by line count.
I just dont understand why 3 extra variables have to be created (I also dont understand...
I agree.
im also confused as to why you have variable names x,y,z and e. to me that means the e is special, significant in some way.
also, why do you have 3 lines of arithmetic? as opposed to...
you have your printf("a\b...}"); in the middle of a for loop. so everytime you find a matching pair you are printing the entire line. you need to take it out of the for loop and print it only once....
it is true that you can use loops and recursion to write this program, but the first step is to understand what you are trying to do and solve the problem, and then turn that solution a C program.
...
this works.
ive bolded the changes
despite its name, getchar works with integers, not chars. I think this program will still work if you have char repeat, but it should be an integer. I believe...
I think you want
guess [0] == guess[1]
to be true. but you also want
guess [0] ==guess [2]
to be true at the same time
lets start from the beginning
1) do you know what a binomial coefficient is?
2) do you know the formula for the binomial coefficient?
be sure that you understand your problems
the point of small programming exercises isnt to finish, its to help you learn the language. if you write 10 programs, but are still making the same...
I think you should begin by first writing each of the functions in the header file, dont worry about the main for now.
you might also like to write a test function so that you know your functions...
while (scanf("%d%d",&n,&k)==2)
{
goes to
while (scanf("%d%d",&n,&k)==2) {
strcat adds on the second string to the end first string. so you have to leave some space at the end of the first string. for example
char date1[20]="Dec 29, 8:30";
char date2[20]="Dec...
char array[] = "Sep 29, 19:34";
printf("length of string is %d\n", strlen(array));
that code will definitely produce a result of 13
what does your code look like? particularly the line...