home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

need n00b c++ help

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1592
Discussions: 200,988, Posts: 2,379,866, Members: 246,356
Old October 5th, 2004, 11:21 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Oct 2004
Posts: 3
Exclamation
need n00b c++ help

hey all: i am in my second semester of c++ programming, and that is the extent of my experience with it. im looking for some help:

i cant figure out how to find the substring by modifying the following code:

char *mysubstr(char *substr, const char *src, int first, int length){
// returns substring of src starting at position "first" and having the size "length"
char *rez = substr;
char *srcstart = first;

if (((first < 0) || (length < 1)) || (length > sizeof src))
{
substr = '\0';
}
else
{

for (;*src != '\0';src++);
for (; ;*substr = ;substr++)

}
return rez;
}

it's supposed to be what the library uses, so i cant use any library calls. i just need to complete the code.

int first = the location of the first letter of the substring on the source string
length = the length of the substring off of the first location

thanks alot. this is my first post here, so hello all!

Jesse
faruquehabib is offline   Reply With Quote
Old October 5th, 2004, 11:52 PM     #2 (permalink)
I am a banana!
 
originel's Avatar
 
Join Date: Jun 2002
Location: Texas Tech
Posts: 3,921
Send a message via AIM to originel
the first thing i notice is that this is a rather odd style. obviously some stuff was left out of the of the loops among other things.

are you allowed to change what is there? personally i think it's rather poor programming style to have that type of conditional in a for loop. that's just my opinion though. also the "*substr =" should be "*substr == X" where X is something else.

also i will say that the first for loop is probably to find the length of the string, or at least the length of something most likely. The second is where the actual substring is copied.

also, why is the substr pointer passed if it returns the value? honestly this is not a good way of approaching the problem.

the first easy thing i noticed is that it should be sizeof(src) instead of sizeof src in the if statement.

btw, welcome to techimo!
originel is offline   Reply With Quote
Old October 6th, 2004, 12:05 AM     #3 (permalink)
Junior Member
 
Join Date: Oct 2004
Posts: 3
thanks alot!

i will try to mod the code. yes, i agree it is an odd style. i will try to fix the things that are messed up and try it..
faruquehabib is offline   Reply With Quote
Old October 6th, 2004, 12:10 AM     #4 (permalink)
Junior Member
 
Join Date: Oct 2004
Posts: 3
attached is the entire project so you can see what the deal is. we are supposed to try to figure out what the code is in the libraries, so we know how the things work that we utilize.
Attached Files
File Type: doc stringpointersworddoc.doc (33.5 KB, 63 views)
faruquehabib is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
WTB:: VIAGRA!!!!!!!!!!!!! Buzioid Traders Forum: Buy, Sell, Trade 20 November 24th, 2003 11:56 AM
Is everybody n00bs here? x86MeOneMoreTime Linux and Unix 99 July 20th, 2003 07:20 PM
I wanna try linux ZENYO Applications and Operating Systems 40 December 15th, 2002 01:34 PM
hi im new! kidblount IMO Community 19 August 15th, 2002 04:52 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (3066)
Charges against non-tippers dropped.. (20)
Health Care Rationing (11)
Delete an OS (17)
Nvidia GTX 260 problem (10)
Laptop with wireless problem. (12)
windows vista security holes (19)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
Regular Build (11)
Point and Shoot Camera Suggestions. (8)
windows 7 problem (7)
[F@H SPAM 11/16/09] ! 1/2 months to.. (39)
Internet Lost (5)
Recent Discussions
Desktop Calendar Application (1)
Can a page file be "too big".. (1)
Nvidia GTX 260 problem (10)
Point and Shoot Camera Suggestions. (8)
Looking for new motherboard (0)
Size after cutting 700Mb file is 2.5 .. (0)
Delete an OS (17)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (39)
windows vista security holes (19)
updating BIOS via winflash, claims fi.. (1)
New Server Configuration Suggestions (0)
cheap gaming laptop? (12)
Unallocated Space (2)
help me pls laptop just stopped worki.. (1)
C# + LINQ Help (7)
Dynex DX E-402 (3)
EVGA 9800 gtx help with finding a goo.. (12)
Multiple Restarts Required at Boot (5)
cell phone won't work (0)
Is the PSU I received dead? (15)
Can't open Word (12)
Steam ID's, Gamertags etc... (4)
Games, Cables, PCI cards, and more fo.. (6)
Dept. of HS: NSA 'Helped' Develop Vis.. (17)
Linksys WMP54GS wireless card problem.. (5)


All times are GMT -4. The time now is 06:47 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28