« first day (473 days earlier)      last day (4466 days later) » 

10:00 PM
hello all
 
@LearningC Use an array of 256 characters and pray to Dennis Ritchie nobody will ever enter more than 256 characters. That's how we do it in C.
 
@FredOverflow fgets allows you to enter the size of the output buffer.
 
my professor said there is a way of getting a line of text without having to put it into an array
 
@LearningC What?
 
10:04 PM
@LearningC Where else would it be stored instead?
 
A string is an array.
 
Sorry my termanology is a little bit off
 
When you read text, you have tu put it somewhere.
 
I see in the transcript I was the subject of some discussion
lol
 
I mean without have to put a limit to an array
 
10:05 PM
Nah.
 
@TonyTheLion No, we were talking about a different Tony :P
 
well my assignment is to change the case of a sentence that someone enter. How do I do this without array?
 
@LearningC Well, you can use "growing arrays". That is, try a 10 element array, if that's not enough, double to 20, if that's not enough, double to 40 etc.
 
@LearningC The problem is, you don't know how much memory you'll need.
 
@MooingDuck yea right
coughs
 
10:06 PM
@LearningC Read one character, change the case, write it somewhere.
 
@LearningC Just process character by character. No need to store the whole thing.
 
Repeat until you read an end of line character.
 
well the assignment said he will enter an line of text
 
@MooingDuck so what is with ducking mooing where you come from?
I thought that cows were known for mooing.
 
@TonyTheLion I don't know what you're talking about
 
10:07 PM
perhaps, in the USA things are different :P
 
The truth is, reading "a line" in standard C is a pain.
 
which one would be best for this? scanf or fgets?
 
#include <stdio.h>
#include <ctype.h>
int main()
{
    int c;
    while ((c = getchar()) != '\n')
    {
        putchar(toupper(c));
    }
    return 0;
}
 
@MooingDuck your nick is "Mooing Duck"
@RMartinhoFernandes C is a pain.
 
@LearningC scanfis for formatted reading. fgets is for reading a whole string.
 
10:08 PM
you were being too specific
 
thanks for the answer. But I was hopping I can learn while doing this
 
So much pain that there's a libreadline providing only a readline function whose sole purpose is to read a line (I'm lying, it does a bit more).
 
hopping????
@RMartinhoFernandes LOL :P
 
hoping =)
 
C++ also has a getline()
 
10:09 PM
getchar reads a character from standard input. toupper returns the uppercase version of a character. putchar writes a character to standard output.
 
so getchar will get a character?
 
Yes, that's why it's called getchar. It gets a char.
 
oh rly?
 
Ya rly.
 
can't I use 'while (c = scanf(%s, c) ! = EOF)?
 
10:11 PM
EOF is End of File
 
%s scans a string, not a character
 
No need to use scanf.
 
@LearningC you can, but it doesn't do what you want
 
File != Console
 
And explain why that would work.
 
10:11 PM
yea I know what EOF is
 
scanf returns the number of records read. Or something.
 
@TonyTheLion EOF in console is simply Ctrl+Z in Windows and Ctrl+D or something in Unix.
 
oh
I had no idea
always learning
 
The more you know...
 
@FredOverflow it only works sometimes though, I think it has to immediately follow a newline or some nonsense
 
10:12 PM
oh right
 
Who's talking about console? stdin is a file, and that's where scanf reads from.
 
@RMartinhoFernandes Tony is
 
anyone familiar with list's in scheme?
 
@renatofernandes I used to, but I try to forget about it.
 
10:13 PM
@renatofernandes My other car is a cdr!
 
too many parens
 
My teacher was a pain in the balls.
 
@RMartinhoFernandes stdin is a file? Where is that written?
 
@FredOverflow Blu-Rays are all the rage these days.
 
@TonyTheLion It's a FILE *.
 
10:13 PM
@TonyTheLion In the C library. extern FILE* stdin;. Or something.
 
cause i have C assignmnet where they represent lists in struct using pointers
 
int main(){

while (c=getch() !=EOF ){
prinf("%s", c);
}
return 0;
}
 
@LearningC did you try it?
 
@RMartinhoFernandes ah.
 
@LearningC What you want is to read until the end of the line (that is, \n). That will read until the end of the file.
 
10:15 PM
what is wrong with that?
 
@LearningC c=getch() !=EOF is parsed as c=(getch() !=EOF). Probably not what you want.
 
Yeah, that also.
 
I think it's time to change the tag line of this room
 
Also, printing a single char as a string is a very bad idea.
 
been too long
 
10:15 PM
Anyway, the end of file in a console only happens when you type some special Ctrl+Whatever.
 
@TonyTheLion The fact that the user will be dealing with a console doesn't change anything from your program's point of view. Because the user could, in fact, just invoke your program with input redirection: $ program < somefile works on all Big Three OS command lines.
 
oh really
 
right
 
so, != "/n" is better?
 
@LearningC \n, not /n.
 
10:16 PM
@RMartinhoFernandes wow! Cool.
 
'\n'. Single quotes too.
 
!= '\n' is better if you want to process only one line. Which seems to be what you want as far as I can tell.
 
Actually, printf("%s", c) invokes undefined behavior. You should use %c.
 
1 min ago, by FredOverflow
Also, printing a single char as a string is a very bad idea.
 
Indeed.
 
10:17 PM
how does printf know the different between a single char or a string of them? Does it count them or something?
 
It doesn't know.
That's the problem.
 
@TonyTheLion It doesn't. There's %s for char * and %c for char.
 
... is how you spell type-unsafety in C.
 
When you pass the char it gets promoted to int.
 
sbi
@TonyTheLion room topic changed to Lounge<C++>: I think it's time to change the tag line of this room. [c++] [c++11] [c++-faq]
 
10:18 PM
When printf sees %s it will fetch a pointer, but there will be an int there.
 
@RMartinhoFernandes standard printf only does int and double, right? I mean what it actually fetches from the stack, not the format strings. Or rather, what is actually passed.
 
yea but it distinguishes between a string and a char
 
No, it doesn't.
 
oh, just learned that ideone will #include "curses.h"
 
@sbi thanks. I wanted to put something witty, however
 
10:19 PM
If you don't choose the right format specifier, you get undefined behavior.
 
sbi
@TonyTheLion Mhmm. Lemme think...
 
@FredOverflow Pointers too, and long longs on C99.
 
is it bad that I'm in intermediate C, when I'm struggling with the basics?
 
ah char* and char
there's the difference
 
sbi
room topic changed to Lounge<C++>: Something witty here. [c++] [c++11] [c++-faq]
 
10:20 PM
now it makes sense
 
@LearningC C is not an easy language.
 
@sbi ffs
 
when scanf read's input, i want to press control-d and do something with the input, how do i do that?
 
@RMartinhoFernandes Okay so passing ... means promotion to int, double or void*?
 
sbi
10:20 PM
@TonyTheLion I won't put that into the tagline.
 
@renatofernandes What exactly do you want to do with the input?
 
I wish you could pictures in the tag line
then we could have titties :P
 
We have those on the Haskell room's tag line.
 
boobs
 
10:21 PM
kay so i type numbers like 1 2 3 and then i want to return the reverse so.. 3 2 1
 
sbi
@TonyTheLion room topic changed to Lounge<C++>: Something titty here. [c++] [c++11] [c++-faq]
 
room topic changed to Lounge<C++>: ((.).(.)) [c++] [c++11] [c++-faq]
 
( . ) ( . )
 
Feel free to change to your needs ;)
 
thanks for the boobs :)
 
10:22 PM
lol
 
sbi
@FredOverflow How primitive! At least make it a valid lambda expression. (In C++, not in Haskell!)
 
@renatofernandes why on ctrl+D? Why not at the newline?
 
lambda boobs?
 
Yeah, in the Haskell room it's valid, meaningful Haskell.
 
My primary aim was to please @RMartinhoFernandes with the Haskell boobs.
 
10:22 PM
oh yea, that reminds me, I need continue my Haskell book
 
void(*)(...); looks funny though
 
I was on Sections
 
Here it's just a bunch of symbols.
 
#include <stdio.h>

int c;

int main(){

while ((c=getch()) !=EOF ){
prinf("%c", c);
}
return 0;
}
 
"(.)(.)" Fixed.
 
sbi
10:23 PM
@FredOverflow See, @Tony, he just used you to wank off his Haskell.
 
cause i assumed when i press control-d on my interaction window that means i finished inputting my input
 
I didn't quite understand the point of sections in Haskell
 
getting error when compileing
 
@TonyTheLion Hop in there, I'll explain :)
 
oh wait
 
10:23 PM
@sbi I kinda like Haskell, so I don't mind it
 
sbi
@TonyTheLion Wimp!
 
@renatofernandes ah, you're using linux? Read until EOF then
 
@LearningC You misspelled printf.
 
@LearningC <stdio.h>
 
10:24 PM
wow
 
yess i am, how do i input that as code?
sorry im very unifamiliar with scanf
 
@sbi me? a wimp???
 
z:~/enee150/homework1: gcc -o hw1_1_2 hw1_1_2.c
Undefined first referenced
symbol in file
getch /var/tmp//ccyVSvFH.o
prinf /var/tmp//ccyVSvFH.o
ld: fatal: symbol referencing errors. No output written to hw1_1_2
collect2: ld returned 1 exit status
z:~/enee150/homework1:
 
2 mins ago, by FredOverflow
@LearningC You misspelled printf.
 
Isn't it getchar?
 
10:26 PM
@renatofernandes eh, basically the same code as LearningC has, except without the bugs?
 
#include "stdio.h"

int c;

int main(){

while ((c=getch()) !=EOF ){
printf("%c", c);
}
return 0;
}
 
@RMartinhoFernandes getch is (sometimes) in conio and in curses.h
 
still getting the same error
 
Using getch instead of getchar causes very weird effect in my XP console.
 
int main(void){
int number;
while (1 == scanf("%d",&number)) {
printf("%d\n",number);
}
return 0;
}
is tht okay?
 
10:28 PM
Seems so.
 
Did you #include <stdio.h>?
 
ideone.com will compile this for me?
 
yes i did fred
 
@LearningC yes
 
10:29 PM
wow that cool
 
so i have this code
 
Program works perfectly for me. Are you sure you're compiling that program and not another one by mistake? Because if you're still getting the prinf error without the t, you must be doing something wrong. Did you forget to save the source code or something?
 
int main(void){
int number;
while (1 == scanf("%d",&number)) {
printf("%d\n",number);
}
return 0;
}... when i press control-d i want to produce the interfergs i have inputted in reverse order so if type 1 2 3 ... once i press control-d it return 3 2 1 ... is this possible?
 
@MooingDuck Where did the input come from?
@renatofernandes What is an interferg?
 
10:30 PM
im using gcc -o hw1_1_2 hw1_1_2.c
 
intergers*
 
@renatofernandes you'll need to change the line printf to something. When it reaches teh ctrl+D, it'll do whatever is after the while loop
@FredOverflow my left hand
@LearningC use getchar instead. And give it some input data to test with
 
yay it printed out the line
 
sbi
room topic changed to Lounge<C++>: If you love C++, then you did not use it enough. [c++] [c++11] [c++-faq]
 
how would i do that :S
i kno i need to use pointers to store the values and return them in reverse order
 
10:33 PM
@renatofernandes Is this homework? Have you learned arrays yet? Loops? Recursion?
#include <stdio.h>
void yay_recursion(void)
{
    int number;
    if (1 == scanf("%d", &number))
    {
        yay_recursion();
        printf("%d\n", number);
    }
}
int main(void)
{
    yay_recursion();
    return 0;
}
 
yes it is hmwk i know loops and recursions
 
@renatofernandes Inside the while loop you need to store the characters in an array. After the while loop you need to print the characters in the array in the reverse order
 
sbi
Took me a while to dig this out, @Tony. Sigh.
Now I really need to got to bed. Good night, namaste, and schlaft schön!
 
@MooingDuck no need for arrays thanks to recursion ;)
 
@sbi Boa noite.
 
10:34 PM
@FredOverflow eh, I find arrays simpler to conceptualize
 
How can anything be simpler than recursion?
 
@RMartinhoFernandes doing it right
 
Recursion in C is way simpler than arrays in C ;)
 
im not allowed to use recursion or array's ... i am given a bunch of functions thou, is anyone willing to look at the question in detail?
 
@renatofernandes wait, no recursion or arrays? Then it's impossible
 
10:34 PM
Oh, arbitrary restrictions.
 
well the funtions they give us help
 
You are not allowed recursion? That is, you are not allowed to define a function and call it? How stupid is that?
 
i just dont know how tou use them
 
@sbi dig what out?
 
@renatofernandes which functions are they?
 
10:35 PM
@renatofernandes Can you show us the "funtions they give us help"?
 
@TonyTheLion the topic I'd imagine
 
clicking
 
Ah, so you have a list. Then just use that list instead of an array, done.
 
okay click
its the backward.c funtion
im tryin to do tht one
 
10:38 PM
So just use the list as a kind of stack. Start with the empty list, cons the new elements at the front, and when the user is done, pop the elements from the front until the list is empty again. Should get you the reverse order.
 
as a kind of stack?
 
#include <stdio.h>

int c;

int main(){

printf("Please enter a line of text");

while ((c=getchar()) !=EOF ){
if ((c >= 65 )&& (c <=90) ){
c = c+32;
}else if ((c >= 97 )&& (c<=122)){
c = c-32;
}
printf("%s", c);

}
return 0;
}
 
@renatofernandes you put things on the top of a stack, you take things of the top of a stack, you never touch the middle
 
Fernandes number 2 has arrived :P
 
Xeo
10:39 PM
Does anyone know that guy?
 
I bet his mother does.
@LearningC Again, printf("%s", c); is a very bad idea. Use %c instead. Or even better, putchar(c).
 
what if the input is more than 3 wouldnt the middle matter?
 
yea just changed that it and it worked
 
@renatofernandes You only ever touch the front of the list.
 
@renatofernandes then you put the fourth on the top of the stack. The number of ints shouldn't matter if you do it right
 
10:41 PM
alrite so from this code ...
 
Here is the curriculum vitae of the list:
 
@Xeo you talking about the bronekk guy?
 
empty
10
20 10
30 20 10
20 10
10
empty
 
Xeo
@TonyTheLion Aye
 
@FredOverflow latin? really?
 
Xeo
10:42 PM
And it seems that guy is on the committee and invented ref qualifiers :)
 
seems he wrote some C++11 feature
 
What do I put to end the program after it printed the reversed text?
 
@MooingDuck I don't know the English term for curriculum vitae.
 
int main(void){
int number;
while (1 == scanf("%d",&number)) {
printf("%d\n",number);
}
return 0;
}.... where would i go from this code?
 
Scrolling too fast.
 
10:42 PM
@LearningC return 0;
 
Xeo
> Extending move semantics to *this (revised wording) Bronek Kozicki
 
@Xeo rvalue ref qualifiers or lvalue ref qualifiers?
 
fred do i not use pointers?
 
@FredOverflow I think it's "resumé". But that would sound silly.
 
I have that at the end but it wont exit. it will stay there
 
10:42 PM
4 mins ago, by FredOverflow
So just use the list as a kind of stack. Start with the empty list, cons the new elements at the front, and when the user is done, pop the elements from the front until the list is empty again. Should get you the reverse order.
 
@FredOverflow google suggests "the course of life" but I don't think that's a good translation
 
@RMartinhoFernandes Isn't "resumé" french? :)
 
@LearningC are you using Visual Studio 2008?
 
@FredOverflow Ok, maybe some English speakers write it "resume" because they can't handle accents.
 
@renatofernandes Why on earth would you use pointers? The instructions specifically state that you must use ilist.
 
10:44 PM
@ Mooing I'm using on my school UNIX server, over putty
 
oh ok..
 
@LearningC What is "it" in "it will stay there"?
 
@LearningC eh, try CTRL+C? (might be CTRL+D, and I'm pretty sure it's not CTRL+Z)
 
@Xeo do you already understand the difference between prvalues, xvalues, glvalues?
 
my first step is how to make scanf read my input .... ?
 
Xeo
10:45 PM
@TonyTheLion .. mostly?
 
z:~/enee150/homework1: hw1_1_2
Please enter a line of text: adka ; 1 2 JAKasd 8UuRtS
ADKA ; 1 2 jakASD 8uUrTs
it will stay under the A
 
or when should scanf save my input when i click control-d
 
@renatofernandes What do you mean "make scanf read my input"? Aren't you already doing that?
 
it should exit back to terminal right? since I have return 0;
 
@Xeo oh, I don't
 
10:46 PM
my bad i meant make scanf stop when i click control-d
 
@TonyTheLion Didn't we have this conversation before?
Or was it only about l/r values?
 
@renatofernandes Do you get any output for that program?
 
@RMartinhoFernandes it was only about l/r values
and I know the difference now
 
@renatofernandes Easier. Place all your input in a file, and then invoke your program like program < somefile.
 
but not prvalues, glvalues and xvalues
 
10:47 PM
Ah, I see.
 
funnily enough I remember the names of these weird ones
 
So you grok the idea of identity already?
 
though I have no idea what they are
 
@renatofernandes Can you show us a screenshot of your problem?
 
10:48 PM
@LearningC The last code you posted will read all input until there is no more input to get ever, and then display one character. Since a keyboard can enter more, it's waiting. Did you try CTRL+C or CTRL+D?
 
Xeo
prvalue - "pure" rvalue, `X foo();` return value is a prvalue
xvalue - `X&& move()` for example
glvalue - `X& bar()`
 
from this code int main(void){
int number;
while (1 == scanf("%d",&number)) {
printf("%d\n",number);
}
return 0;
} iwant to save the input when i click control-d ?
 
Xeo
Is how I understand it atleast
And yes, I was just bitten by multiline markdown
 
problem as in the question?
 
@Xeo not a bad example
 
10:48 PM
@renatofernandes you have to save the input as you get each one. By the time it scans CTRL+D, the input should have already been saved, or it's lost
 
@Xeo Don't worry, I lost track of the count.
 
Xeo
@TonyTheLion I just hope that it's correct. xD
 
oh ok
 
@renatofernandes Instead of printf("%d\n",number); you want to put the number into an ilist. And when the loop is done, you want to start a second loop that consumes the elements from the list.
 
Well, prvalues have no identity at all. They're "pure rvalues". Everything not a prvalue is is a glvalue.
 
Xeo
10:49 PM
Also, nearly all "value" keywords are prvalues - true, false, nullptr, this and others
 
I wonder if Bjarne knows the difference?
 
alrite lemme try ...
 
@Mooing yea I had to use CTRL+C, but is there anything I can do to the code so it will exit me to terminal when done? such as changing while (((c=getchar()) !=EOF) ||((c=getchar()) != "\n") ) ?
 
rvalues are movable. Those with identity are xvalues, those without are prvalues. Everything not an rvalue is an lvalue.
 
xvalue is the result of a moved value?
 
10:50 PM
@LearningC no, not really.
 
Xeo
@TonyTheLion No, it's the result of move (and forward when forwarding an rvalue)
 
@RMartinhoFernandes rvalues with identity? like foo() ?
 
@TonyTheLion Bjarne was heavily involved in the working group that produced the new value categories. So yes, Bjarne knows what an xvalue is.
 
@ Mooing ok thanks
 
@TonyTheLion Like std::move(x).
 
10:51 PM
Thanks for the help everyone.
 
@FredOverflow oh cool. Thanks for clarifying :)
 
@LearningC oh actually, (((c=getchar()) !=EOF) && (c!='\n') ) might work. I had misunderstood
 
@RMartinhoFernandes cause what you're moving x to has identity?
 
int main(void){
int number;
while (1 == scanf("%d",&number)) {
ilist x = iempty();
ilist y = icons(1,x);;
}
return 0;
}
 
@TonyTheLion std::move does not move.
 
10:52 PM
@renatofernandes better! (still not quite right)
 
@renatofernandes You want to create the list before the first loop. And you're still missing the second loop to consume the list.
 
@FredOverflow indeed, it has no legs, it can't move
 
@FredOverflow Oh no, is it dead?
 
so why is it called std::move when it doesn't move?
 
@Mooing yup that worked perfectly
 
10:53 PM
@TonyTheLion Because it enables moving.
 
Because std::make_it_an_rvalue was silly.
2
 
@LearningC oh good, I was unsure if I got the () paired right
 
it should have been std::enable_move
C++ IS FUCKING CONFUSING!
 
@TonyTheLion it displays the intent. x = move(y) vs x = enable_move(y)
 
10:54 PM
I like std::move.
 
std::move(it)
 
@CatPlusPlus How about std::i_promise_to_forget_about?
 
sooo .... int main(void){
int number;
ilist x = iempty();
while (1 == scanf("%d",&number)) {
ilist y = icons(1,x);;
}
return 0;
} ... where would i add the second loop ?
 
@Mooing why is it && not ||?
 
What std you promise to forget about?
 
10:55 PM
@LearningC Because x != some_value || x != some_other_value is always true.
 
Also, what's with consing in here?
 
@LearningC (((c=getchar()) !=EOF) && (c!='\n') ) becomes if (the variable c (as assigned from the keyboard) was able to be read) and (the variable c was not a newline)) then continue
 
ohhh right!
 
I'm confused.
 
10:56 PM
ohh ok that make sense
 
!(x || y) == !x && !y
 
man I learn more in the past hour than I did last semester.
 
good old De Morgan
 
@renatofernandes after it finishes the scanning loop, then it will display, but before it returns from the program to the console
 
I don't I'll ever really understand r-value references and move semantics, there's something about it, that always manages to get me confused again and again. every. damn. time
meh
 
10:57 PM
@TonyTheLion Have you ever implemented your own string class or vector class template? Because if you haven't, it's too early in your C++ career to dive into move semantics.
 
@FredOverflow highly recommended
 
@TonyTheLion They're defined for convenience and correctness, not for semantic simplicity.
 
@FredOverflow only if it's a g-string :)
 
Wait, what?
 
They're pretty easy.
 
10:58 PM
no, I have never implemented my own string class
 
Just use them, don't try to learn before using. Trial and error is a good idea here.
 
What can I use on Linux to replace MSPaint?
 
@RMartinhoFernandes A virtual box with windows (I'm not a good source of help)
 
@RMartinhoFernandes gimp
 
Paint.NET works on Mono, I think.
 
10:59 PM
@FredOverflow I'd only do something for fun or to learn from, not write it in production code
 
@CatPlusPlus WinForms is quirky on Linux.
 
@TonyTheLion I suggest sticking to understanding lvalues and rvalues. Rvalue references aren't that interesting.
 
@TonyTheLion obviously
 
@RMartinhoFernandes wut? Gimp? Krita?
 
@TonyTheLion And that prohibits you from learning about move semantics?
 
10:59 PM
Or did you especially require it to suck?
 
@FredOverflow no
 

« first day (473 days earlier)      last day (4466 days later) »