Thread: function insanity

  1. #1
    Unregistered
    Guest

    function insanity

    omg this is driving me nutz!!!!!!!

    i want to make this code into a function...

    #include <stdio.h>
    #include <iostream.h>

    int main(int argc, char *argv[])
    {
    printf("%S",argv[0]);
    cout<<argv[0]<<endl;
    return 0;
    }

    i have tried hundreds of ways and i am about to go insane!!!!!!!!!

    this is one of my many pittifull atempts!!!!!

    char Findname()
    {
    printf("%S",argv[0]);
    cout<<argv[0]<<endl;
    return argv[0];
    }

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    156
    give this a try

    Code:
    #include "stdafx.h"
    #include <iostream> 
    using namespace std;
    
    void printArgs( int nNumOfArgs, char * szArgs[] );
    
    int main(int argc, char *argv[]) 
    {
    
    	printArgs( argc, argv );
    
    	return 0; 
    } // end
    
    void printArgs( int nNumOfArgs, char * szArgs[] )
    {
    
    	for( int i = 0; i < nNumOfArgs; i++ )
    	{
    		cout << szArgs[ i ] << endl;
    	}
    
    }

  3. #3
    Unregistered
    Guest
    do i really have to make that complicated?
    all i want is a function that i can call that gives the location and name of the program currently running...

    anyways thx for your help

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    156
    Well give this a try

    Code:
    #include "stdafx.h"
    #include "windows.h"
    #include <iostream> 
    using namespace std;
    
    int main() { 
    	
    	char szFileName[ MAX_PATH + 1] = {0};
    	GetModuleFileName( NULL, szFileName, MAX_PATH+1 );
    	
    	cout << szFileName << endl;
    
    	return 0; 
    } // end

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  5. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM