Thread: hmm

  1. #1
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765

    hmm

    Code:
    int main()
    {
    	int pgm;
    	char inbuf [130];
    	printf("Input file: ");
    	gets(inbuf);
    	scanf(inbuf, &pgm);
    	system("&pgm");
    	return 0;
    }
    Floating point formats not linked.
    Abnormal program termination.

    Where's the mix up?
    The world is waiting. I must leave you now.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    What exactly are you trying to do?

    1) gets(inbuf);

    Never ever use gets.

    2) scanf(inbuf, &pgm);

    Again, what exacatly are you doing?
    Do you know how to use scanf?

    scanf( thisformat, thisvariable )

    so, unless you're inputting like ... "%d""200" ... then your program won't work.

    3) system("&pgm");

    You realize that you're passing the string "&pgm" to your OS? Do you actually have a program called "&pgm" on your computer? If not, then this is not what you want. I will bet you any amount of money you want that this is not what you want.

    4) return 0;

    Hey, at least you have that right...

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    I will bet you any amount of money you want that
    Yes, I do. Programming is something I probably shouldn't be doing right now ( bare with me lol ). Yeah though, I want to pass whatever the use types ( whatever ) to the operating system.
    The world is waiting. I must leave you now.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > Yeah though, I want to pass whatever the use types (
    > whatever ) to the operating system.

    Which is not what you're doing. You're passing a string that is "&pgm". "&pgm" is nothing. It's not a variable. It's not the address of a variable. It's simply a string containing 4 characters (pluss null).

    Assuming you read into a character array, called 'foo', you'd do:

    system( foo );

    The name of an array may be treated as a pointer. Thus, a character array who's name is 'foo', may be used as a pointer.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentation Fault hmm?
    By pobri19 in forum C Programming
    Replies: 4
    Last Post: 05-03-2008, 07:51 AM
  2. hmm i think i broke something (power supply)
    By MisterSako in forum Tech Board
    Replies: 1
    Last Post: 02-11-2006, 11:32 PM
  3. hmm, easy problem from by book.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 01-07-2003, 11:14 PM
  4. hmm.....
    By D4050 in forum C++ Programming
    Replies: 4
    Last Post: 10-03-2001, 02:13 PM
  5. hmm, newbie AGAIN? ;)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-05-2001, 08:17 AM