Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Prog2
/
labor_peldak
/
lab_extra
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fae6dab5
authored
6 years ago
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v0
parent
490e6527
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
string2/string2.cpp
+3
-3
No files found.
string2/string2.cpp
View file @
fae6dab5
/**
/**
* EZ EGY HIBÁS megoldása a 6. heti labrofeladatnak!
* A problémák az üres string kezelésével kacsolatosak
* A String + String művelet megvalósításában memóriavesztés is lehetséges
...
...
@@ -92,13 +92,13 @@ String String::operator+(const String& rhs_s) const {
String
temp
;
// ide kerül az eredmény
// Meghatározza az új string hosszát
temp
.
len
=
len
+
rhs_s
.
len
;
// lefoglalja a memóriát az új stringnek.
temp
.
pData
=
new
char
[
temp
.
len
+
1
];
// Az elejére bemásolja az első stringet
strcpy
(
temp
.
pData
,
pData
);
// Bemásolja a második stringet.
strcat
(
temp
.
pData
,
pData
);
strcat
(
temp
.
pData
,
rhs_s
.
pData
);
return
temp
;
// visszatér az eredménnyel
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment