Anonymous
a point points to the adress of a variable but its not a memory adress but a pointer has also to a memory adress
Anonymous
a point points to the adress of a variable but its not a memory adress but a pointer has also to a memory adress
what? no. a pointer holds a numeric value (like any other variable, they're all represented in binary [as 1 and 0]), and this numeric value is an address in the virtual memory of the process. if, for example, you'll print the value of a pointer you'll get the virtual address it represents (the virtual address of the value it points to)
Anonymous
bro i mean its a big differnce of that : *pointer and that &reference
Anonymous
anyways, if you try to convert a pointer to an int and that int back to a pointer, and in your machine the size of a pointer is smaller than the size of an int (which is mostly the case), you'll get a trimmed value, and that address will be undefined
Anonymous
That is the big disadvantage of c.Its not type safe
what? how so? the same will happen in cpp
Anonymous
no
Anonymous
cpp handles typ safety better
Anonymous
but you right its the same thing
Blue
Cpp is not type safe out of the box. But you can achieve it with disciplined programming
Blue
I dont use c# so I dont know
Anonymous
Hey guys how to count how many times a number appears in a 2d array? I've tried some method but didn't worked
linear search every row/column(if elements are unsorted) - expensive binary search every row/column(if elements are sorted) - less expensive , but still expensive.
Anonymous
after struggling, tried to do a bubblee sort, but... https://gist.github.com/Kamuri-chan/9ac977ec90c11e5295c64f0154cd60ef
why ? #define MAXLIMIT 255 you could have also used, In line 46, int matrix[value_x][value_y];
Anonymous
Anonymous
resolved creating one 1d array, sorted with bubble sorting and counted every element
wait, so you first took one row, sorted it using bubble sort, and then counted every element in that particular row?
Hariyana Grande
can we learn data structure along with c lang(im beginner in c lang)?
Shadow
in cpp char arr[10]={'h','e','o'} where will be null character stored?
Shadow
in which case null will be stored automatically inside char array?
Ammar
It won't be
BTW, it is an exception. If you initialize a sized array partially, the rest will be initialized with zero. So basically int arr[3] = {1}; arr[1] and arr[2] will be zero.
Ammar
See also https://stackoverflow.com/a/201116/7275114
Ammar
Suppose if it is fully filled?
Then it is what it is filled. That is not the point anyway. I know exactly what @VoidStar0x0 talking about. He means string literal like "Hello World" ends with null char.
Ruth
Hey guys
Ruth
#include <iostream> #include <fstream> using namespace std; int n; //Globaal viriable used in forloops in the functions class Student1 { public: string name, fn; string sex; double grade; Student1() {} Student1(string n, string fn, string s, double g); void data(Student1 s); //used to display all student info void filter(Student1 s); //used to filter out female students and display friend ofstream &operator<<(ofstream &ofs, Student1 &s); friend ifstream &operator>>(ifstream &ifs, Student1 &s); }; int main() { Student1 s; Student1 *list[n]; cout << "Enter number of student " << endl; cin >> n; for (int i = 0; i < n; i++) { cout << "enter name of student number " << i + 1 << endl; cin >> s.name; cout << "enter father name of sudent number " << i + 1 << endl; cin >> s.fn; cout << "enter Sex of student number M/m" << i + 1 << endl; cin >> s.sex; cout << "enter Grade of student number " << i + 1 << endl; cin >> s.grade; list[i] = new Student1(s.name, s.fn, s.sex, s.grade); } ofstream ofs("regi.txt",ios::app); for (int i = 0; i < n; i++) { ofs << list[i]; } Student1 student_list; ifstream ifs("regi.txt"); cout << "student data " << endl; cout << "***** Name SEX GRADE****" << endl; for (int i = 0; i < n; i++) { ifs >> Student1 list; } int choose; cout<<1 << "enter 1 for to diplay all student data" << endl; cout<<2 << "enter 2 for to diplay female student data" << endl; cin >> choose; switch (choose) { case 1: s.data(s); break; case 2: s.filter(s); default: break; } } Student1::Student1(string n, string fn, string s, double g) { name = n; fn = fn; sex = s; grade = g; } void Student1::filter(Student1 s) { if (s.sex == "f" || s.sex == "F") { for (int i = 0; i < n; i++) { cout << "Name " << s.name << endl; cout << "Father Name " << s.fn << endl; cout << "Sex " << s.sex << endl; cout << "Grade " << s.grade << endl; cout << endl; } } }
Ruth
#include <iostream> #include <fstream> using namespace std; int n; //Globaal viriable used in forloops in the functions class Student1 { public: string name, fn; string sex; double grade; Student1() {} Student1(string n, string fn, string s, double g); void data(Student1 s); //used to display all student info void filter(Student1 s); //used to filter out female students and display friend ofstream &operator<<(ofstream &ofs, Student1 &s); friend ifstream &operator>>(ifstream &ifs, Student1 &s); }; int main() { Student1 s; Student1 *list[n]; cout << "Enter number of student " << endl; cin >> n; for (int i = 0; i < n; i++) { cout << "enter name of student number " << i + 1 << endl; cin >> s.name; cout << "enter father name of sudent number " << i + 1 << endl; cin >> s.fn; cout << "enter Sex of student number M/m" << i + 1 << endl; cin >> s.sex; cout << "enter Grade of student number " << i + 1 << endl; cin >> s.grade; list[i] = new Student1(s.name, s.fn, s.sex, s.grade); } ofstream ofs("regi.txt",ios::app); for (int i = 0; i < n; i++) { ofs << list[i]; } Student1 student_list; ifstream ifs("regi.txt"); cout << "student data " << endl; cout << "***** Name SEX GRADE****" << endl; for (int i = 0; i < n; i++) { ifs >> Student1 list; } int choose; cout<<1 << "enter 1 for to diplay all student data" << endl; cout<<2 << "enter 2 for to diplay female student data" << endl; cin >> choose; switch (choose) { case 1: s.data(s); break; case 2: s.filter(s); default: break; } } Student1::Student1(string n, string fn, string s, double g) { name = n; fn = fn; sex = s; grade = g; } void Student1::filter(Student1 s) { if (s.sex == "f" || s.sex == "F") { for (int i = 0; i < n; i++) { cout << "Name " << s.name << endl; cout << "Father Name " << s.fn << endl; cout << "Sex " << s.sex << endl; cout << "Grade " << s.grade << endl; cout << endl; } } }
this is my code and i can't compile it ......please help me
Oleg
this is my code and i can't compile it ......please help me
bruh... could you please paste your code on a website that can provide tabs and spaces otherwise it's hard to read
Nova
this is my code and i can't compile it ......please help me
Firstly you can't use "list" as object name
Oleg
there is no implemented function with name "data"
Ruth
there is no implemented function with name "data"
i don't understand .....i wrote this code function with file
Oleg
where? I see Student1 class, main function, constructor and filter. Moreover, you've declared overloading "< <" and "> >" but you have not realized them.
Hamid
g++ -I.\include\ -L.\lib\ .\test\tpdf.cpp .\lib\jagpdf-14.dll -o test.exe ?
Exit with code 5. I think that's how i should compile it but somehow the library has problems
Юрій
Anyone can help, i need to craft upd packet (directly i need to change IP address of sender and receiver, and data sent) How could I do that, maybe there are any library?
Suka
Exit with code 5. I think that's how i should compile it but somehow the library has problems
it can be. try build your own dll for simple task like hello world. to check your toolchains is ok.
Ruth
ok thanks all😊😊
armandofsanchez
ok thanks all😊😊
I dont recommend fn=fn
Ruth
I dont recommend fn=fn
when i wrote fname=fn it shows error so i change it (father name) in to fn
Ed
Is it recommended to use the goto label? if not what are the implications?
Giorgi
Is it recommended to use the goto label? if not what are the implications?
goto can screw up code in scalable code. In modern C/C++, it is discouraged to use it.
Ed
Ok. Thanks.
Dima
lol
Dima
wtf
Giorgi
Giorgi
I don't understand why the link was deleted
Dima
why does it block wiki links lol
Dima
just paste it with spaces
Giorgi
Spaghetti_code on wikipedia
Giorgi
that is what goto leads to
Dima
https://en.wikipedia.org/wiki/Spaghetti_code
Giorgi
jesus, if I link it gets deleted
Oleg
probably labels are allowed in assembler code,but not exactly in the languages like c++
Anonymous
You little cow
Oleg
Mario, you can kill a lot of people, but you won't, right?
Oleg
Sorry, Au, I can't help you with the loop.
Oleg
ok thanks all😊😊
I tried to rewrite your code as there are many errors in the previous one. Maybe it'll help.
Anonymous
https://pastebin.com/w5SX3qNH
Oleg
I should train)
Giorgi
Question: what libraries do you use most?
Oleg
stl, boost, qt
.
I have questions e.g there is independent classes having their own linked list structures and there is a another class having a pointer to the node type Is there any way i can get the head of the first data structures need help
Aze
txns rose am seriously interested in c++, learning resources and materials would be appreciated
Ruth
https://pastebin.com/w5SX3qNH
Ohh it work thanks a lot
Anonymous
Thanks for adding me