What the fuck are you talking about? When the program ends, nothing remains.
huh?
What the fuck are you talking about? When the program ends, nothing remains.
huh?
Now, when u asked, i don't know how i know but i know if u know what i mean.
Yes, it does remain. If new operator is used u need to delete explicitly.
p.s. And yes, this does loop forever if functionCall() really returns 3
variable would be successfully set to functionCall()'s return value
no way, variable is set to true, because functionCall()!=0 is true. in this case true means 1
fstream header will do. just include <ifstream>
then do
ifstream vname("filename");
vname >> array; as many times as needed
or In #5 in the code you can change line 14 from if(str[i] < str[j])
to if(toupper(str[i]) < toupper(str[j]))
.
Well, i just transformed your own code. Used string str
instead of char* a[100]
and char tmp
instead of char* tmp[100]
(u need just one character to bubble-sort, not an array).
You would like to use strings in c++ instead of char arrays in cases like this, because it's much easier to do so. Like you can write string1 = string2 instead of strcpy.
that's all
Introducing bubble sort :)
#include <iostream>
#include <string>
int main()
{
std::string str;
std::cin >> str;
char tmp;
int i,j;
for(i=0;i<str.size()-1;++i) {
for(j = i+1;j<str.size();++j) {
if(str[i] < str[j])
{
tmp = str[i];
str[i] = str[j];
str[j] = tmp;
}
}
}
std::cout << str;
return 0;
}
This works.
Look, you have that #include<string.h>
right? So why don't you use c++ strings? It's like
string str;
str = "whatever"
and it's easier.
Now this
for(int b=0;b<=(strlen(a)-1);b++)
{
for(int c=0;c<=(strlen(a)-2);c++)
{
if(strcmp(a[c],a[c+1])<0) //I DON"T THINK THIS IS RIGHT
{
strcpy(temp,a[c]);
strcpy(a[c],a[c+1]);
strcpy(a[c],temp);
}
}
}
is a mess. You could just compare a[c] < a[c+1] cuz this are characters, not strings and they are already sorted in ASCII.
Could you please explain what the program is supposed to do?
new allocates dynamic memory (did i choose the right words?).