• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Tamanon

Banned
Hi smart-GAF :)

I thankfully landed a summer job Which requires me to develop ios applications. I started reading up on objective c and noticed most tutorials are using Xcode on macs. I only have a PC, will I need to invest in a mac to start program in objective C to develop ios applications?

Thanks in advance!

You are in luck. MS just announced that Visual Studio Code will allow you to do Obj-C coding.

https://code.visualstudio.com/

But, if you're going to be doing that more than just an internship, you'll eventually want to get a Mac I would say.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
If your doing full fledged iOS dev at a shop I would imagine you would need an actual Mac. This is so that you can handle debugging and testing. If they require that though, I'd think they'd have a spare Mac in house that you could use.

Otherwise there's lots of options for doing development outside of Obj-C and Xcode if they aren't picky.
 
Hi smart-GAF :)

I thankfully landed a summer job Which requires me to develop ios applications. I started reading up on objective c and noticed most tutorials are using Xcode on macs. I only have a PC, will I need to invest in a mac to start program in objective C to develop ios applications?

Thanks in advance!
Yeah, you'll want a Mac just to walk down the path of least resistance.

There's enough rapid change with Apple's APIs and dev tools that you'll really want to be using their stuff, even if you decide that you're happier with a third party alternative in the long run.

Plus, Swift is moving fast and you will want to be on board that train. Certainly you'll want to get familiar with Objective-C for now, but Swift has and will continue to have some really interesting developments that you won't see outside of Apple platforms for some time.
 
For programming? If the company's serious about iOS development, they'll give their developers a Mac. Even if they're interns.

I don't know all the circumstances behind this job, and it would help if you asked your employers what they'll provide. But if they're seriously expecting you to develop without a Mac, that's a big red flag that you'll be stuck on a less-good middleware framework or some other awkward solution that's going to give more pain than just using the officially endorsed tools.

truthfact, I haven't had to buy any new hardware for full-time programming in some time. In every case, the company has provided it for me.
 

tokkun

Member
He didn't say he was working for a company; could be contract work. There is a lot of that on iOS these days. I see a lot of fliers put up by "idea guys" looking for someone to create the app they dreamed up.
 
Aw, shucks. You're right, Tokkun, it could be one of them.

Granted, it could be a really bizarre learning experience and I like to think I've learned something new even from the people who had no clue what they were trying to do.

Really, my response comes from variations of the how to do iOS without a Mac question since 2008. The not Mac options are still not great.

If you want a Mac on a tight budget, Apple's increasingly hard to get to refurbished store is a good option to pick up a Mac Mini that will get you down that path without paying out the nose. I would recommend the 2.6 Ghz option if you can swing it, Xcode can be demanding and Swift has only just started to be optimized for faster compiling.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Hell, I'd love to have enough iOS knowledge to do side work. I imagine it would be a pain at times, but I bet the money would be nice. (Especially for a poor college student, haha)
 
Ever have one of those moments where you spend a long time on a problem only to realize it's significantly easier than you thought because you misunderstood what it was asking? Those moments suck.
 

hateradio

The Most Dangerous Yes Man
Anyone have any tips for an Android list that contains two sub lists?

I've tried using a typical ArrayAdapter, but the sub lists (A and B) implode on themselves and only show the first item of their respective list.

I've looked at the expandable list view, but I've only seen it with one sub list, not two.

This is my goal.

g1gZEWe.png


Note: The image should say "Base List" not "Base Lists."
 
I've calmed down a little after some teething, but there are still some inconsistencies that seem a bit off. For example, it seems you have to include function implementation for templated classes in the header file?

Templates are a complicated beast. The thing to understand about templates is that they cause the compiler to generate code. A single template function could result in 100 different functions being generated. For example, if you write foo<int> and foo<double>, the compiler will generate two completely different functions.

Why is this important? First, let's look at how a compiler works with a non-templated function. it sees something like this in a header:

Code:
struct Foo
{
   void foo();
};

It mangles the function name and produces something like ?foo@Foo@@QAEXXZ So now it says "ok there's a function called ?foo@Foo@@QAEXXZ. Any time someone calls this I'll write the call into the object file as ?foo@Foo@@QAEXXZ, and hopefully later some cpp file will contain a definition of this function. So I'll just let the linker figure it out at the end after every file has been compiled".

So it happily goes along, and later on sure enough some cpp file defines this function. At that point the compiler says "I've just compiled this function called ?foo@Foo@@QAEXXZ, so I will write its name and definition into my object file". Lnd later still, after all compiling is done, the linker says "ok I see there's a definition for a function called ?foo@Foo@@QAEXXZ. I will put its code at address 0x12345678. And over here is some code that calls that same function. I'll write the call instruction into the executable as calling the function at 0x12345678, since that's where I've placed the code for this function in the executable."

Everybody's happy.


Now consider the case of a template function. Suppose you had this:

Code:
// File a.cpp
void f()
{
    Foo foo;
    foo.foo<int>();
}

// File b.h
struct Foo
{
   template<class T>
   void foo();
};

// File b.cpp
#include "b.h"
template<class T>
void Foo::foo<T>()
{
}

When it compiles a.cpp, it does the same thing as in the previous example. It says "ok I've got this function named ??$foo@N@Foo@@QAEXXZ". (note that this function has a different mangling. It has an @N near the beginning. If you change int to double you'll get an @H instead. Every type will produce a different mangling). "I'll put it into my object file as before, and let the linker figure it out". Then it compiles b.cpp. Now it says "hmm, I've got this template function, but I don't know what type the template parameter is supposed to be. What am I supposed to do? How many functions do I write into the object file, and what should they be called?" Why doesn't it know that someone else called it with foo<int>? Remember compilation happens in parallel. One file, one process. The process that compiled a.cpp might have ended a long time ago. Hell, a.cpp might not have even been compiled yet. So b.cpp has *no idea*. Not only does it not know *how* to generate the code, but it doesn't even know what to call the function it generates. So the compiler is stuck here, it doesn't know what to do, so it just skips the function and does nothing. At the end you get an unresolved symbol error from your linker, because the compiler didn't generate code for the integer instanation.

You can actually "help" the compiler here. For example, in b.h you can explicitly instantiate it with a line like:

Code:
void Foo::foo<int>();

This will cause compilation of b.cpp to know that it needs to generate an instanation with an int, so when it compiles b.cpp (which includes b.h), the compiler will see this and everything will work.

The problem with this approach, of course, is that the b.h needs to know in advance every possible way that the template will ever be instantiated. If you ever use it a different way, you'll get a linker error at the end.


Now, if you're astute, you might be thinking "Well linkers already do link time code generation, and the linker knows every possible instantiation. Why can't the linker just generate the code for all these instantiations?" And the answer is, it can! Kinda. In fact, if I'm not mistaken this is the way in which the EDG compiler implemented the export keyword (which was basically something in the standard that allowed compilers to work exactly the way in which you were hoping it did work). But this path is fraught with peril.

One of the issues with the export keyword (and generating code for template instanations at link time) is that compilation is highly parallel. Every compilation is run in a different process. You can compile as many files at once as you have cores on your machine. Linking, on the other hand, is highly serialized. The whole point is to take many inputs and produce one output, so by its very nature it has to serialize somehow. This may seem like a minor inconvenience but if you consider how many instanations of templates come from things like the standard library and when you start doing metaprogramming, it becomes really prohibitively expensive. It's easy to imagine a program with millions or even billions of template instanations.

LTCG is a relatively new thing anyway, so even if it were possible to do it efficiently, you lose a ton of potential for optimization. The compiler has so much more knowledge about your program. type information, semantics, data flow analysis, etc. And compiler optimization is really just an exercise in data flow analysis. So programs would not only build significantly slower as a result of doing this, but they would run much slower as well. Linking is already the slowest part of a large build anyway. By making each compilation do a little extra work (namely, instantiating all the templates every time in every process) it may be more overall work, but it gets done faster because it can be parallelized.

Then, there is the issue of how much is even possible in the linker? Although the linker would be generating code, it would be generating it based on a template that you wrote. When it does LTCG for optimization purposes, it can be assured there are no errors because it's not generating it based on user input. It's like the adage of "make sure you sanitize user input". Code you write is user input to a compiler. If the linker were to generate the code for your templates, it may encounter errors in your code. Does the linker now get into the business of reporting compiler errors? It's not immediately obvious that there's a good solution here.

Finally, it's not even clear that it could be standards conformant. Since the linker doesn't have the same level semantic information as the compiler, certain advanced features like SFINAE (beyond the scope of this post, feel free to google it though) may not even be made to work at all.


I know this is a long post, but hopefully this clears some things up!


Edit: By the way, you should have a look at C++ Modules. It's a C++ language feature originally planned for C++11 which was removed from C++11 for technical reasons. It's still on the slate for inclusion in a future versino of the standard, the next of which is C++17. Clang has already started working on implementing it and has made significant progress.

Implementing modules essentially solves a lot of the same problems required for implementing the export keyword in the compiler. I'm not up to date on the latest details regarding modules and how they interact with templates, but my understanding is that modules will open the door to fixing the inline template definition problem.
 

Wynnebeck

Banned
Ok guys got a dilemma. I'm in my Intro to Programming class and our final program project is doing arrays. We were supposed to list the arrays and then write them in reverse and etc. My prototypes I have to use are:

void getlist (int [], int &);
void putlist (const int [], int);
void reverse (const int [], int);
void EvenValues (const int [], int);
void GreaterThan (const int [], int);

This is what I have so far:

#include <iostream>
#include <iomanip>
using namespace std;

const int MAXSIZE = 25;

void getlist (int [], int &);
void putlist (const int [], int);

int main()
{

int list [MAXSIZE];
int num_items;

getlist (list,num_items);

putlist (list,num_items);

system ("pause");
return 0;
}

void getlist (int list [], int& num_items)
{

int i;

cout << "Please enter the number of array values ";
cin >> num_items;

for (i = 0; i < num_items; i++)
{
cout << "Enter the next array value " << endl;
cin >> list ;
}
}

void putlist (const int list [], int num_items)
{

cout << "Array Elements" << endl;

for (int i = 0; i < num_items; i++)
cout <<i << " " << list << endl;
}


My problem is that I have no idea where to go next to make it run in reverse and I'm freaking out. Here was the parameters given:

1. Write a C ++ program to read numbers (using the count technique or a sentinel loop) into an array of integers, and then manipulate the array. Declare the array of size 25 (range 0 to 24). Use a function to read the array. Then do the following exercises.
2. (1 and 2 are worth 20%) Print the array, writing the indexes and components.
3. (25%) Write the array and indexes in reverse order, that is, the zero component will be written last.
4. (25%) Write the indexes and components were the array values are divisible by two. Test the array components, not the indexes.
5. (30%) Write the indexes and components where the component is greater than the value in the next position. Note that there will be no defined value after the last to compare.

Can anyone at least point me in the right direction? I'm so confused right now.
 
Ok guys got a dilemma. I'm in my Intro to Programming class and our final program project is doing arrays. We were supposed to list the arrays and then write them in reverse and etc. My prototypes I have to use are:



This is what I have so far:



My problem is that I have no idea where to go next to make it run in reverse and I'm freaking out. Here was the parameters given:



Can anyone at least point me in the right direction? I'm so confused right now.

Hint: You should be able to do the reverse function by changing exactly line of code of your putlist function. Think about how that function -- and in particular the loop construct -- works.
 

Onemic

Member
How successful would you say calling companies up to see if they'll hire you as a volunteer is? If it is successful, how would you suggest I would approach such a request?
 
How successful would you say calling companies up to see if they'll hire you as a volunteer is? If it is successful, how would you suggest I would approach such a request?

As a volunteer software engineer? Just out of curiosity, how hard have you tried to find a paying job, and what's your skill set?
 

Onemic

Member
As a volunteer software engineer? Just out of curiosity, how hard have you tried to find a paying job, and what's your skill set?

Im not finished my program yet(Have one more year left), so I dont think I can say Im a full fledged software engineer yet, heh. Im not looking for a permanent position since Im going back to school in the fall. I really just need a job where I can try and apply some of the things I've learned in school so far.

So far in my program I've learned: C, C++, PHP, HTML/CSS/JS, Java(with intros on basic RMI), SQL(MySQL and Oracle specifically), and Rational Rose

I also learned RPG/CLLE, but I've totally forgotten everything about those languages.

I'd definitely say I'm strongest in C++ and Java
 
Im not finished my program yet(Have one more year left), so I dont think I can say Im a full fledged software engineer yet, heh. Im not looking for a permanent position since Im going back to school in the fall. I really just need a job where I can try and apply some of the things I've learned in school so far.

So far in my program I've learned: C, C++, PHP, HTML/CSS/JS, Java(with intros on basic RMI), SQL(MySQL and Oracle specifically), and Rational Rose

I also learned RPG/CLLE, but I've totally forgotten everything about those languages.

I'd definitely say I'm strongest in C++ and Java

I think you could find an internship or something, no need to sell yourself short as a volunteer. When I first started I was basically in the same situation, just looking for a part time position to get some hands on experience. Found a job for a small privately owned startup, 5-10 employees doing random stuff, but at least it was some pay (i think it was like $8 / hour, but this was a really long time ago).
 

Onemic

Member
I think you could find an internship or something, no need to sell yourself short as a volunteer. When I first started I was basically in the same situation, just looking for a part time position to get some hands on experience. Found a job for a small privately owned startup, 5-10 employees doing random stuff, but at least it was some pay (i think it was like $8 / hour, but this was a really long time ago).

I'll keep trying then. So far I've applied to 20 or so jobs since I finished exams last week with no call backs, which is sorta discouraging. Not to mention I have a ton of pressure on me by my parents to get a job in my field this summer. So anything, even if I dont get paid, would be better than nothing.
 
I'll keep trying then. So far I've applied to 20 or so jobs since I finished exams last week with no call backs, which is sorta discouraging. Not to mention I have a ton of pressure on me by my parents to get a job in my field this summer. So anything, even if I dont get paid, would be better than nothing.

Maybe you could look on Craigslist or something similar? I hate to say "lower the bar", but if you're looking on a major job website, then chances are tons of people are applying to those same jobs. You want to find a posting that's a little bit more... i don't know, personal. Something where it seems like the actual person who wants to hire you is the one that wrote the posting and put it up. Not saying it's easy, but I think it will be easier to find a paying job than a volunteer job. Because, i don't know, tha'ts just a little weird.
 
I'll keep trying then. So far I've applied to 20 or so jobs since I finished exams last week with no call backs, which is sorta discouraging. Not to mention I have a ton of pressure on me by my parents to get a job in my field this summer. So anything, even if I dont get paid, would be better than nothing.

Have you tried speaking with any professors you're closer to about potential opportunities? I know at my university there are software positions within the school where you work under a professor and basically do the implementation of their research.
 

Onemic

Member
Maybe you could look on Craigslist or something similar? I hate to say "lower the bar", but if you're looking on a major job website, then chances are tons of people are applying to those same jobs. You want to find a posting that's a little bit more... i don't know, personal. Something where it seems like the actual person who wants to hire you is the one that wrote the posting and put it up. Not saying it's easy, but I think it will be easier to find a paying job than a volunteer job. Because, i don't know, tha'ts just a little weird.

I'll try that. I will say I've totally overlooked Craigslist and Kijiji...unsure why especially considering that I got my last job from Craigslist, haha.

Have you tried speaking with any professors you're closer to about potential opportunities? I know at my university there are software positions within the school where you work under a professor and basically do the implementation of their research.

Ive emailed a bunch that I received either a B+ or higher in this week and have yet to receive a response from any of them. My guess is that they don't look at their school email after exams, or only look at it sporadically during the summer.
 
Keep applying. Keep looking. 20 seems like a lot, but I probably crashed and burned at around 40 places before I got my first (real) job of out school. The vast majority without so much as a phone interview. Trying to break in with no experience isn't impossible, but it's usually not pretty. Unless you know somebody, of course!

(this is why job fairs are such a big deal. But I was too young and stupid to realize that at the time!)

However, once you've been settled for a few years and have the requisite buzz words on your resume to go along with some experience, recruiters won't leave you alone.

edit: I don't think I conveyed how much the process sucks when you're on the outside looking in though. It sucks. It feels completely hopeless. All I can say is that it's not as bad as it seems!
 
Anyone else have trouble coming up with personal projects?

Since I'm a student I can get Xamarin for free so I can create Android apps in C#. I think that'd be a cool summer project but I just can't come up with the ideas.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
I tend to get my ideas by building stupid silly small projects. It usually leads to more ideas for me.

edit: Now that I read this, my comment isn't very useful. But I can't think of a way to phrase it better tonight.
 
Anyone else have trouble coming up with personal projects?

Since I'm a student I can get Xamarin for free so I can create Android apps in C#. I think that'd be a cool summer project but I just can't come up with the ideas.
I felt like a failure for the first couple of years in college because I could never find a project that was interesting while everybody else was creating mobile apps, web servers, browser extensions and so on.

I finally found a project that was just plain exciting to me and worked on that. It was the only project on my resume, but it made my last interview because the interviewers kept smiling the whole time I'm gushing about what I learned in it and how it applies to them.

Don't be discouraged. Just keep learning and you'll eventually find a passion project.
 
Anyone else have trouble coming up with personal projects?

Since I'm a student I can get Xamarin for free so I can create Android apps in C#. I think that'd be a cool summer project but I just can't come up with the ideas.

Xamarin is cool, i would also suggest looking into MvvmCross its a framework that enables
the mvvm pattern. Makes multiplat development really awesome, personally a better
framework then Xamarin.Forms but Forms is quiet young so it could take a couple of
years to mature.
 

mercviper

Member
Anyone else have trouble coming up with personal projects?

Since I'm a student I can get Xamarin for free so I can create Android apps in C#. I think that'd be a cool summer project but I just can't come up with the ideas.

Yeah I have no idea what to do for personal projects. I need to think of what I want to do for senior project. All I can really think of is that I want to port a board game over to a web UI so I can play long distance with some friends but when I talk to my profs about projects they seem to want something that deals with research or new tech. :/
 

Tacitus_

Member
So I got drafted to a school summer project to do an orienteering help app for android/mobile. It'll be either native android or apache cordova.

Anyone here have experience using a maps api for either google or OSM?
 
So I got drafted to a school summer project to do an orienteering help app for android/mobile. It'll be either native android or apache cordova.

Anyone here have experience using a maps api for either google or OSM?

I've done projects on Google Maps (JavaScript) API but mainly for Street View. There's also an Android API for that. The documentation is pretty good and there's tons of examples online.
 

Tacitus_

Member
I've done projects on Google Maps (JavaScript) API but mainly for Street View. There's also an Android API for that. The documentation is pretty good and there's tons of examples online.

Yeah the gmaps API looks nice, but we're not sure if we fit in the free version of it. Will know more tomorrow when we get the official specs.
 

Onemic

Member
Maybe you could look on Craigslist or something similar? I hate to say "lower the bar", but if you're looking on a major job website, then chances are tons of people are applying to those same jobs. You want to find a posting that's a little bit more... i don't know, personal. Something where it seems like the actual person who wants to hire you is the one that wrote the posting and put it up. Not saying it's easy, but I think it will be easier to find a paying job than a volunteer job. Because, i don't know, tha'ts just a little weird.

Coincidentally, my professor just got back to me about summer job opportunities. He said there was a volunteer position available within the open source department of my college. Told me to ask for a specific person and mention that he sent me to inquire about a volunteer position.

So I guess if this pans out, I'll do the volunteer stuff while also still looking for an actual paying job?
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Coincidentally, my professor just got back to me about summer job opportunities. He said there was a volunteer position available within the open source department of my college. Told me to ask for a specific person and mention that he sent me to inquire about a volunteer position.

So I guess if this pans out, I'll do the volunteer stuff while also still looking for an actual paying job?

Experience is experience. So long as you can afford to volunteer, it's a great way to learn
 

Slavik81

Member
How successful would you say calling companies up to see if they'll hire you as a volunteer is? If it is successful, how would you suggest I would approach such a request?
This is a bad idea. It's very expensive to train a new developer. The $20/hr they might pay you is only a fraction of your cost. You'll need a desk, tools, paperwork filed and many hours of direction and mentoring by experienced developers. It's likely you won't even be of net productivity for a month or more. For any profitable company, your take-home pay is probably not a make-or-break difference for hiring you. Plus, it's illegal. If you're doing work for a for-profit company, they need to pay at least minimum wage.

The only companies who would take you up on your offer would be companies that are neither concerned with the law, nor with training you. You do not want to work for them.
Coincidentally, my professor just got back to me about summer job opportunities. He said there was a volunteer position available within the open source department of my college. Told me to ask for a specific person and mention that he sent me to inquire about a volunteer position.

So I guess if this pans out, I'll do the volunteer stuff while also still looking for an actual paying job?
On the other hand, this is fine. Universities are generally not for profit and have a lot more brains than money.

Volunteering with the open source department of your college is reasonable. Probably a second choice after a paying position, but if money's not an issue, I'd stick with them for whatever duration they expect of you.
 
File IO is boring. That is all
Wrong!

fsync()
my favorite is the OSX "implementation"
, blocking vs non-blocking, ionice, safe replace semantics (tmp file + rename), file permissions and umasks, mmap(), symlinks and hardlinks, file attributes! There's a lot to keep it interesting if you look for it!

And if you're up for some serious fuckery, there's always the Windows stuff to "enjoy"...
 
I need help with homework, it's on linked list. I have to implement a member function which I will name it check_list which will check if the number is in the list. I want to check with you guys if this code is correct.

Code:
[B]implemention file:[/B]
bool LinkedLists::check_list(int number){
	if(number < 1 || (number > getSize())){
		return false;
	} else {
		Node *current = head;
		//cout << "The integer " << check << " is in the list.";
		for(int i = 1; i < check; ++i){
			current = current->next;
		}
		return true;
	}
}

[B]main:[/B]

int main{
     cout << list.check_list(4);
}
 

tokkun

Member
I need help with homework, it's on linked list. I have to implement a member function which I will name it check_list which will check if the number is in the list. I want to check with you guys if this code is correct.

Code:
[B]implemention file:[/B]
bool LinkedLists::check_list(int number){
	if(number < 1 || (number > getSize())){
		return false;
	} else {
		Node *current = head;
		//cout << "The integer " << check << " is in the list.";
		for(int i = 1; i < check; ++i){
			current = current->next;
		}
		return true;
	}
}

[B]main:[/B]

int main{
     cout << list.check_list(4);
}

They want you to check if any node in your list contains the value. Your code is only looking at the number of nodes, not the values contained in each node.
 

Haly

One day I realized that sadness is just another word for not enough coffee.
Not quite.

A few issues I see, without going into the details of how to solve it.

1. Unless your assignment specifies otherwise, how can you know that numbers less than 1 and numbers greater than the size of the list can't be in the list? You're confusing two concepts; the indexing/size of the list, and the contents of the list.

For example this a perfectly valid list, which can expressed as a linked list: 0 0 0 0 0 0 0 0 0

Your function would return false for check_list(0), even though 0 is very clearly in the list.

Similarly, this is a valid list: 20

Again, your current implementation would return false for check_list(20).

2. You never actually look the contents of the nodes in the list. There should be a comparison somewhere in there. How would you be find it without one?

3. What is the "check" variable?
 
Wrong!

fsync()
my favorite is the OSX "implementation"
, blocking vs non-blocking, ionice, safe replace semantics (tmp file + rename), file permissions and umasks, mmap(), symlinks and hardlinks, file attributes! There's a lot to keep it interesting if you look for it!

And if you're up for some serious fuckery, there's always the Windows stuff to "enjoy"...

Windows file i/o is a thing of beauty, not even joking. It's so much more flexible than -nix. i/o completion ports in particular are amazing. And all the flags in windows make me drool. Windows API gets a bad rap for being verbose, but while it may be justified to some extent, with that verbosity comes a ton of power. What holds it back is NTFS. Sadly NTFS is just downright sloer than other more modern file systems. I really hope Microsoft can make something happen with ReFS because the windows file api on top of a fast file system would be amazing.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
I think I'm finally finished with my project for my first internship. Tomorrow morning I turn it. This feels awesome and a little terrifying at the same time.
 
Not quite.

A few issues I see, without going into the details of how to solve it.

1. Unless your assignment specifies otherwise, how can you know that numbers less than 1 and numbers greater than the size of the list can't be in the list? You're confusing two concepts; the indexing/size of the list, and the contents of the list.

For example this a perfectly valid list, which can expressed as a linked list: 0 0 0 0 0 0 0 0 0

Your function would return false for check_list(0), even though 0 is very clearly in the list.

Similarly, this is a valid list: 20

Again, your current implementation would return false for check_list(20).

2. You never actually look the contents of the nodes in the list. There should be a comparison somewhere in there. How would you be find it without one?

3. What is the "check" variable?

check variable contains a value that it's comparing with the contents in the list. I understand the description but not sure on how to do it. So we use nested for loops to do it?
 

Haly

One day I realized that sadness is just another word for not enough coffee.
check variable contains a value that it's comparing with the contents in the list.

You never declared a variable called "check" or defined it with a value. It would be redundant anyway, because your function has a local variable called "number". That's what was passed in as an argument in main(), and I'm pretty sure that's what you want to check.

Here's some pseudo-code to get you started.

Code:
Node* current = head
for (i = 0 , i is less than the size of the linked list, ++i) // (get used to counting from 0)
     If the number we are checking is equal to the number inside current, return true
     Otherwise move on to the next node in the list
The loop has gone through the entire list without finding a match, so return false

It helps to describe an algorithm in English to help conceptualize it.

Are you coding in a text editor or IDE (integrated development environment) like Visual Studio? Have you tried compiling and running this code? It should throw a bunch of errors in your face that'll tell you more about your problem. For example, I don't think you actually defined a "list" anywhere. Unless it's in another file supplied by your instructor, there's no way to run tests on it.
 
Top Bottom