int to char or else

I need take every new line and print that.
What can I do with it?
char *str;
int q;
while(!feof(file)){
q = getc(file);
if(q == '\n'){
str=(char*)malloc(100);
*str=(char)q;
printf("%s\n", str); // <- mistake, that printed only parts with '\n'
free(str);
}
printf("%q",q); // <- worked
printf("%s",q); // <- mistake
}
How to transfer value to string and print that string-by-string.
p.s. No told me about use stream and other methods. And help me in that in C, no C++.
_____
Thank in adv.
Last edited on
I found this link somewhere else on this site:

http://www.cprogramming.com/tutorial/c/lesson11.html

Hope it helps
1
2
3
4
5
6
7
string input "";

do {
 cin.getline(input);
 if (input != "")
 cout << "Input was: " << input;
while (input != "");
Last edited on
Topic archived. No new replies allowed.