I have a rudimentary program I'm trying to implement that asks for a URL of a .pdf file and then downloads it and shows it through Xming. First, I want to check to make sure the user actually put in a URL with 'http://' at the front and 'pdf' or 'PDF' at the end. I suppose this might be a typical problem from someone coming from Python, but how do I check end of the string the user inputs. Using the method below (which I used with my Python-oriented-brain) I get a
Range error: -3
So how do ACTUAL C++ programmers accomplish this task? Please and thank you.
if (file[0]=='h' && file[1]=='t' && file[2]=='t' && file[3]=='p' && file[4]==':'
&& file[5]=='/' && file[6]=='/' && (file[-3]=='p' || file[-3]=='P')
&& (file[-2]=='d' || file[-2]=='D') && (file[-1]=='f' || file[-1]=='F'))