dighn

Lifer
Aug 12, 2001
22,820
4
81
don't use aim but if you feel like posting it i'd try to help if i'm still here
 

TheLonelyPhoenix

Diamond Member
Feb 15, 2004
5,594
1
0
Originally posted by: blustori
not hw. wow wat an a$s. im sorri the ppl here at school and the book i have suck at explaining double pointerS?

They must suck at the English language too.
 

blustori

Senior member
Mar 2, 2005
753
0
0
Wow. I guess I should spell like this then. I thought ATOT was a place where I could get some friendly help. I guess I expected too much from some people eh?

dighn pm xP thx.
 
Jan 31, 2002
40,819
2
0
Originally posted by: blustori
not hw. wow wat an a$s. im sorri the ppl here at school and the book i have suck at explaining double pointerS?

Less time on C++, more on English.

Does your resume look like that too?

Edit - btw u shud B doin UR 0wn H/W nsted uv wstn tym3 on pH0rUmZ je3z do0d u r so l4m3 ollolollolol roflcannon wtf bbq kthx bai no0blet

- M4H
 

agnitrate

Diamond Member
Jul 2, 2001
3,761
1
0
Listen jackass, if you posted your questions you might have received a polite response had you shown you ATTEMPTED any work whatsoever.

You're severly limiting your resources by asking for individual PMs when you could have just typed up your damn question once, posted it, and had EVERYBODY who looked at this post read your question and possibly help out. Perhaps you should take a basic logic course first before you attempt to do anything related to this.
 

blustori

Senior member
Mar 2, 2005
753
0
0
I'm sorry I wasn't born a computer genious? I know that there are many EE's that have no idea what is going on when they first try something as complicated as C and I'm one of them. I'm also pretty sure there are a lot of EE's out there that would have been happier if some upperclassmen helped them out.
 

TheLonelyPhoenix

Diamond Member
Feb 15, 2004
5,594
1
0
Originally posted by: blustori
I'm sorry I wasn't born a computer genious? I know that there are many EE's that have no idea what is going on when they first try something as complicated as C and I'm one of them. I'm also pretty sure there are a lot of EE's out there that would have been happier if some upperclassmen helped them out.

By virtue of the facts you...
a) ...didn't ask in the right forum, the trademark of a student scrapping to finish an assignment on the day its due
b) ...didn't post the question here directly, but are asking for AIM help, another sign of someone who wants to copy and paste their spec sheet/code and ask "how do I make this work?"
and c) ...throw out a broad topic like double pointers with absolutely no specific question or example code, whcih means you probably have even attempted to solve your own problem yet and have no clue what you're doing

...you've obviously YA-ATOTerWhoCan'tDoHisOwnWork.
 
Jan 31, 2002
40,819
2
0
Originally posted by: blustori
I will post the question here then. This is an extra credit assignment and it is not due till after finals which are weeks away. And no, I do not want anyone's code, just their logic. So here it is then. Im trying use a double pointer to read in words in a sentence. Here is what I'm thinking. Allocate space for the pointer, read in each word by character and then store it in a temporary char variable. After that I want to copy the temp variable into the pointer. This step is where I'm lost. I also know that after i store the word in the pointer, I will have to realloc memory + 1 for '\0'.

QFIdiocy

- M4H
 

blustori

Senior member
Mar 2, 2005
753
0
0
May I add that ppl with C experience respond only? I rather get some help than be insulted. I know that I'm not the world's smartest programmer. k? thx.
 

anandtechrocks

Senior member
Dec 7, 2004
760
0
76
Wow, this thread has such a warm feeling to it...

Seriously, why do you guys have to be such jackasses? If you don't like the topic don't freaking write in it! I'm sure if no one replies he will get the point and rephrase his question. Are all these lame personal insults really necessary?
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
reallocation is rather expensive i'd think. better to start out with an initial size and reallocate only when you've reached the capacity. but anyway for starting out, it doesn't really matter.

basically say you have double pointer p, p[ i ] would be the ith word, and you should allocate for it a chunk of char eg p[ i ] = malloc(sizeof(char)*SIZE); --> what size to choose? you could set a maximum word length or grow the word if needed. p[ i ][ j ] would be the ith word's jth character. just make sure you terminate each work with a '\0'.
 

mitchafi

Golden Member
Mar 25, 2004
1,594
0
76
Originally posted by: anandtechrocks
Wow, this thread has such a warm feeling to it...

Seriously, why do you guys have to be such jackasses? If you don't like the topic don't freaking write in it! I'm sure if no one replies he will get the point and rephrase his question. Are all these lame personal insults really necessary?

 

blustori

Senior member
Mar 2, 2005
753
0
0
exactly what I was thinking but, the thing is there is no max word length. There could be a word thats 100+ characters long hence the use of a double pointer.
 

agnitrate

Diamond Member
Jul 2, 2001
3,761
1
0
Originally posted by: blustori
I will post the question here then. This is an extra credit assignment and it is not due till after finals which are weeks away. And no, I do not want anyone's code, just their logic. So here it is then. Im trying use a double pointer to read in words in a sentence. Here is what I'm thinking. Allocate space for the pointer, read in each word by character and then store it in a temporary char variable. After that I want to copy the temp variable into the pointer. This step is where I'm lost. I also know that after i store the word in the pointer, I will have to realloc memory + 1 for '\0'.

Why are you using a double pointer for this? Is it required to use double pointers so you can have each word in the sentence as a single element?

i.e.

char **sentence;
sentence[0] -> (pointer) = "first"
sentenc[1] -> (pointer) = "second"
....
sentence[n-1] -> (pointer) = "last"

In that sense? If so, I'd probably allocate the double pointer to store a certain amount of words initially, maybe 32 or something, and then after you read in the 32, you reallocate and give it an additional 32 to work with.

So basically,

creater your double pointer
malloc it so it holds a pre-defined number of words
begin your loop to read in the words
if you've read in more words than your pre-defined amount, realloc the double pointer
store the new word in your double pointer
end loop

That seems about right to me but I might be missing a little bit here and there.
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
Originally posted by: blustori
exactly what I was thinking, but the thing is, there is no max word length. There could be a word thats 100+ characters long hence the use of a double pointer.

word length doesn't really have anything to do with the use of double pointer, you use double ptr because you have an array of arrays (array of words, and words are arrays) --> unless i misunderstood somewhere

reallocating for each character in a word would be far too expensive. maybe set a initial size of 20, if you reach that, add another 20, so on
 

blustori

Senior member
Mar 2, 2005
753
0
0
not reallocating for each character, but for each word* thx dighn i will try it again.