Perherps my teahcer wants us to learn pointer in this way...
Type: Posts; User: winggx
Perherps my teahcer wants us to learn pointer in this way...
how about this line of code?
myNode->thirdNode->firstNode = myNode;
is this right? or should it be
myNode->thirdNode->firstNode = myNode->thirdNode ?
so you mean i should have myNode = malloc(sizeof (triNode));
http://i15.photobucket.com/albums/a396/winggx/midterm.jpg
The link above is the pointer structre I need to create
The following is the code I wrote
struct triNode
{
Suppose I have the following structure and array.
typedef struct name {
char firstName[20];
char lastName[20];
} name
Just a quick question, how large can an int hold?
Is it between -999999999 and 999999999?
does this work?
int num = 999999999 + 1;
thx
so I have been working with C for 4 months now (not so long)
but I am still confused about how to compile a C program..
I am using a mac, and so far I wrote my codes with Xcode, and then I type...
I want to compare two strings and see if they are the same or not
char myString[]="hello";
if (myString == "hello") {
printf ("same\n');
I wrote something like this:
int main () {
char input[5];
scanf ("%c" , input);
scanf ("%c" , input);
So, instead of scanf("%s\n,input), I need to use %c?
and what size of char input[] should I use inside the bracket..?
Would you mind if you can give me an example..?
oh...and I am not allowed...
If I need to write a program that reads a string (a person's name)
then print out the first five characters of the name, how can i do that?
for example:
johnny will output johnn
this is what...
But I need to know when the user has done inputting....
if i dont do EOF checking, is there another way to know the user has finished inputting?
sorry, the code I posted was wrong...
It should be
int main () {
char c[21];
while (scanf("%c\n",c) != EOF) {
Is there something wrong with my code?
I am quite confused about inputing a string and a character...
#include <stdio.h>
#include <stdlib.h>
int main () {
int c[21];
If I have a string like this:
char myString [5];
But I didn't put any characters into the array
does it mean:
myString [0] = '\0'
myString [1] = '\0'
myString [2] = '\0'
If I have a function that consumes a string,
for example,
void myFunction (char *s) {
...
}
I am using a mac, and I wrote a simple code using Xcode
#include <stdio.h>
int main () {
printf ("hello world\n");
return 0;
}
what is the difference between the two:
int main (void)
{
return 0;
}
and
I am learning about binary search tree now.
But I have some trouble understanding what a left perfect tree is.
In my homework assignment, it states this:
A left perfect tree (LPT) is a binary...
ok, thank you very much...
finally i solved my problem, really thx.....
but can someone kindly give me some hints of what a left perfect tree is?
A left perfect tree (LPT) is a binary search...
I have to make a destructive function, called insertbst that allows a user to insert an element into a binary search tree...
here is my code
struct node * bstinsert (struct node *s , struct...
Thank you very much. I understand it now.
I have one more questinn though.
Is it ok if I just use if statement?
I am kind of confused the difference between if and else if...
this is my...
Thanks, it makes more sense to me now.
But hum... even I add return to my first and second statement, is it true that my code is still wrong?
Because the code testing system of my school says it...
I don't understand 13...
what does it mean by go back to the first call?
isn't the function will end after it returns a value?
(**sorry, i am new to C, really appreciate your help)
I still don't quite get it...
I understand the return word makes the difference...but why?
I tried to trace my code, but I can't see what the problem is..
when int i is given, it has to be bigger...