tags:

views:

87

answers:

1

I've written a very simple program that is meant to covert a char to its equivalent ASCII value (eg. A = 65), but I'm getting no output at all. where am i going wrong?

Program: test.c

#include<stdio.h>

int main()
{
  char test = 'c';
  int key = (int)(test);
  printf("%d",key);
  return 0;
}

Bash script to compile and run

gcc -o test test.c
test > output

I always end up with output being an empty file.

+5  A: 

test is also a command line application:

test - check file types and compare values

The proper way of executing your little app would be:

./test > output

karlphillip
Sigh...worked. Now I can go to bed feeling stupid.
xbonez
@karlphillip I was going to note, this is dependent on if it's being ran from linux right? The code would work as he typed it in a windows environment right?
onaclov2000
@onaclov2000 His question is how to run the code on Linux environment and redirect it's output to a file. And yes, I believe the code is compilable under Win.
karlphillip