C/C++ Beginner's Guide and Post Basic Questions here

clmlbx

Technomancer
^^ well First Question It will only work if user Press Enter after Every Input . That I don't want ..

User should/can write in single line With Just pressing Enter at end of it. But it should store in 2-3 variables.


Edit :: sorry I replied without checking, it is working, no need to press Enter..But what to do Second Examlpe.. If I have to skip 'x' in it (if user writes "1280 x 720")
 
Last edited:

sriharsha_madineni

Cyborg Agent
It's been a long time since I worked on Cpp, so I'm not sure of other codes that would explicitly take data into several variables from single line. If I'm not wrong, leaving a space between each variable will work too.

Try the book "Practical Cpp programming" for variations in syntax.

Edit:
Not sure if user inputs 1280x720, it is possible if the variable is a single string, I'm not sure, but it is not possible for integer variables afaik.
 
OP
Liverpool_fan

Liverpool_fan

Sami Hyypiä, LFC legend
In C, the scanf format specifier can be used for format specifiers directly.

Code:
scanf("%dx%d", &var1, &var1)

Not really a C++ programmer, so i don't really remember the equivalent for C++. You can use scanf in C++ by cstdio, though.
 

clmlbx

Technomancer
Yes, spaces are working . Is their way to Eliminate one word from it.. I mean If user writes three words with spaces .. I just want First and third word . ..so just eliminate second Word or one I desire..(1280 x 720)

Yes, I do have practical c++ programming (2002), and also pls some one can share a site where I can get few beginners-intermediate assignments for practicing c++..

thanx for help
 

Vyom

The Power of x480
Staff member
Admin
Yes, spaces are working . Is their way to Eliminate one word from it.. I mean If user writes three words with spaces .. I just want First and third word . ..so just eliminate second Word or one I desire..(1280 x 720)

Yes there is a way. You can use 3 different variables to input 3 words. And just don't use the 2nd variable!
Simple, isn't it?

It's like taking a temporary variable to grab 2nd word, which in your case would be X.
 

clmlbx

Technomancer
^^Yes, I already thought about that. I was just looking for some alternate better way to do it..

Well I was practicing my c++ skills. so WAP to find out PPI of screen.. So user need to enter resolution.. I already did that with old school Way but again I was looking for better alternative.

I will post that programme in this section, "post ur c++........" thread tomorrow morning.
 

mitraark

Decrepit
I am going to do some work on Image Processing , which would require analysing a .pbm file and converting it into a .bin Binary file. I will be using C , file handling for the job , have to pass the file name and output file name as parameters [ in main , argc argv .. ] .

Anyone has any good suggestions of e-books for C File Handling operations ?
 

abhijangda

Padawan
^^^ if you are using Linux then read
Beginning Linux Programming or Linux System Programming Handbook. Both of them are very good books. You will find everything related to Linux Programming in C and yes File Handling is also explained.
Also you can go for Programming in ANSI C by Denis Ritchie.
 

krishnandu.sarkar

Simply a DIGITian
Staff member
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Krishnandu>cd Desktop

C:\Documents and Settings\Krishnandu\Desktop>gcc helloworld.c -o helloworld.exe
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot fin
d -ladvapi32
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot fin
d -lshell32
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot fin
d -luser32
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot fin
d -lkernel32
collect2: ld returned 1 exit status

C:\Documents and Settings\Krishnandu\Desktop>

I'm getting this error on Windows.
 

pramudit

Gaming hardcore
done..... :)
just 1 question, why we dont have to include .h with iostream but with other libraries like math and conio .h have to be included????
 
OP
Liverpool_fan

Liverpool_fan

Sami Hyypiä, LFC legend
<iostream> vs <iostream.h>

And oh math.h et al are used in C, in C++ you use the STL libraries (so no .h and for C libs in C++ its #include<cmath>). And oh forget about conio.h, et al they are non-portable and antiquated.

P.S: Have a thorough reading of this thread. Don't skim the posts.
 

Reaper_vivek

BAN...KAI
@Liverpool_fan and other programmers..I have to ask for my assurance :p Did u guys know this much about coding when u were students or when u started working..

I ask because, I am in my final year and I am interested into coding, but i just know the basics of languages like C, C# and java..like, right NOW my skills aren't enough for making a complete program/project by myself..I am still learning about it, but I just want to know whether I am lagging behind much or not..You may call it a comparative thing but I just want to know, whether to start working really really hard or just continue with my current pace...
 

Vyom

The Power of x480
Staff member
Admin
^^ You wouldn't have ask that question, if you were "interested" in learning any language.

People are not born as experts (or knowledgeable). They become one by learning. And learn they do because they have "interest".

There's no point in working hard, if you are doing it for the lack of heart. That would just seem "a task". A task which would be just unsurmountable.
 
OP
Liverpool_fan

Liverpool_fan

Sami Hyypiä, LFC legend
If you're following Indian education (that includes NIIT and such stuff), then yes you are lagging behind big time and not even close to a respectable standard and can't even begin to compare with International standards.
Mind you, you require good communication skills, and just being half decent for a job as a fresher rather than technical excellence.
 

Reaper_vivek

BAN...KAI
@Vyom..I AM interested, and thus have been reading a lot of books...I needed the assurance because every1 tells me that my coding isn't at the same level as others..And then I see it here on tdf..that you guys know a lot about coding and it fascinates me...So i just wanted to know..But sadly I didn't get the answer...

I have good communication skills but it's the TECHNICAL part I'm currently not good at...I know I don't have to be a genius to land a job at any software developing firm..But I DO need deep understanding of the concepts..

I hadn't been coding for a while now..started again few days ago..But I was always interested and intrigued by how programs solve complex problems..:D
 
Top Bottom